Help with Xcode [how can i do so a button sends me to a specific tab]

Discussion in 'Mac Programming' started by Intelligent, Mar 3, 2014.

  1. Intelligent, Mar 3, 2014
    Last edited: Mar 5, 2014

    Intelligent macrumors 6502a

    Intelligent

    Joined:
    Aug 7, 2013
    #1
    Hey, i made an app in xcode with a bunch of tabs and theres questions, the correct answers sends you to the next question (selectnexttabview) and wrong sends you to the first (selectfirsttabview) But how can do so a button sends me to a specific tab, lets say i have 28 tabs, I'm on tab 1 and want to have a button that sends me to tab 26. How do i do that?

    Thanks!

    lol.
     
  2. Intelligent thread starter macrumors 6502a

    Intelligent

    Joined:
    Aug 7, 2013
    #2
    is it selecttbaviewfromsender? If anyone knows could you please help me.
     
  3. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #3
    First off, don't bump topics (you'll certainly need to wait more than 70 minutes sometimes.) If you have more to say, edit your latest post.

    Second, you shouldn't be designing your UI this way. If you're designing an interface with so many tabs (or views in general, really) or a hidden tab bar, you're probably designing it wrong.

    I'd be willing to bet that you have several views that you've copied and pasted and that you manually entered questions and answers in them. You'll be hard wiring the buttons to always trigger that the user picked right or wrong.

    I suggest that you instead take a moment to learn how to do this properly. Have a single view that all of your questions share and instead programmatically change the contents of the text. Programmatically change which buttons indicate the wrong or right answer.
     
  4. Intelligent, Mar 4, 2014
    Last edited: Mar 4, 2014

    Intelligent thread starter macrumors 6502a

    Intelligent

    Joined:
    Aug 7, 2013
    #4
    Um so that means you can't do what i asked? Because i want a new view without having a new window..
    And also i have already done that, don't mean to sound rude, but i don't really care if thats not "the way" you should do it, it works, and its fun for me.
     
  5. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #5
    I didn't say you couldn't do what you asked - I don't know whether it's possible or not. Although thinking back, I believe you have to give your tabs names and use those names to programmatically select them, if you want to stick with Apple's tab view class and only use public methods.

    I didn't tell you to make a new view or a new window.

    And I don't mean to sound rude, but I wouldn't hire you if I knew you designed stuff this way, and in fact I'd probably fire you if I discovered it if you somehow slipped through the interview process. This isn't a matter of opinion - there's not a single experienced programmer that will tell you your design is a good one. Setting the bar as "it works" is awfully low and apethetic to the future people who want to read, understand, maintain, debug, and update your project.
     
  6. Intelligent thread starter macrumors 6502a

    Intelligent

    Joined:
    Aug 7, 2013
    #6

    But it doesn't matter if you wouldn't hire me or not, its a private project, no one else than me is going to use it.
     
  7. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #7
    If ArtOfWarfare wouldn't hire you because of your design, it means that you will also run into trouble with your own home project. The old joke is: Programmers know only three numbers: None, one, and many. 28 is not on that list.

    Oh well, it has to be said: Looks like ArtOfWarfare doesn't like Intelligent Design :D
     
  8. Intelligent thread starter macrumors 6502a

    Intelligent

    Joined:
    Aug 7, 2013
    #8

    So far i have not run into any problems, why do you just go off topic, i though people were nice on these forums, but guess i was wrong...
     
  9. Red Menace macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #9
    You most likely haven't had any problems because you don't have that many questions, but expand to a couple of hundred and you will see what they are talking about (if you are really up to 28 tab views you should already see what they are talking about). The solution would probably be the same either way - you have an array (or dictionary) of questions/answers, or an array of tabViews, so just index into the array for the desired item(s). Take a look at some of the other methods in the NSTabView Class Reference, for example selectTabViewItem:, selectTabViewItemAtIndex:, etc.
     
  10. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #10
    People are nice here.

    So nice, they are trying to teach you to fish rather than giving you one.

    The basic answer you were given was "I don't know, because that's a suboptimal approach. Here's a more standard one".

    "And also i have already done that, don't mean to sound rude, but i don't really care if thats not "the way" you should do it, it works, and its fun for me."

    Was your reply. OK. Well, you've decided you want to strike out on your own, doing something in a strange way. You assert "it works", but you're having trouble with the approach. It's great to blaze your own path, but it's a bit odd to get upset when folks don't know where to go next when you've gotten yourself stranded.

    I am positive what you want to do is possible, but it would be much easier to replace contents of a single view. If you took that approach, others would be able to help you more readily because it's a standard pattern.

    I'm unclear why this thread got as heated as it did. It's really common for people to give a good answer here that doesn't exactly fit the question.

    -Lee
     
  11. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #11
    Ha, I've not heard that one before. I wonder if it's possible to come up with style rules to effectively enforce the idea behind that joke...

    I don't understand what you're saying. Am I being insulted? Is there something I need to learn about?
     
  12. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #12
    The OPs username is Intelligent and his design is abrasive.
     
  13. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #13
    Hah - I missed the fact that Intelligent was the OP's username. It was quite confusing to me that they had capitalized the phrase.
     
  14. Intelligent thread starter macrumors 6502a

    Intelligent

    Joined:
    Aug 7, 2013
    #14
    Aw come on, don't insult me, please don't talk off topic, and if its so bad to have different views how can i have a view change on a button without using a new tab view?
     
  15. Red Menace macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #15
    Check out the NSButton Class Reference. You can easily set the button title and image (and just about any other property) programmatically, unless this is the reason for using tab views.
     
  16. Intelligent thread starter macrumors 6502a

    Intelligent

    Joined:
    Aug 7, 2013
    #16
    Thats not what I'm referring to lets say this smiley is a window [:)] and when i click it i want it to change to this [:):)] and the only way i have found a way to do that is multiple views.
     
  17. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #17
    Then have two smilies in your view. Have the first one always visible and don't show the second one visible until after the button is clicked.

    For your program, you should be programmatically changing the contents of your text field that presents your questions and the contents of the buttons that present your answers. You'll need to also keep track of which button holds the right answer (I suggest shuffling the options around so people can't just memorize where the right answers are). Feel free to ask for more help if you need it.
     
  18. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #18
    I've read all of your posts in this thread and am not sure what you really want. Do you want to be able to randomly select another tab, or do you want to specifically change from specifically one tab to just one other tab, such as tab 1 to 26 out of the 28 tabs?


    I'm not insulting you. I was reflecting the view others have, that I agree with, and was responding to ArtOfWarfare's questions.


    This doesn't explain what you really want any better than your original post.

    Come up with a very clear explanation and post images if it can help others understand your needs.


    As others have mentioned, you can use one view, lay down the labels or text values you need onto that view, and update them for each Q&A set. You'd index the Q&As and access them as needed to place them into the labels. As mentioned, if these are multiple choice, then each time you display them, you should randomize the order in which they display.
     
  19. Intelligent, May 11, 2014
    Last edited: May 11, 2014

    Intelligent thread starter macrumors 6502a

    Intelligent

    Joined:
    Aug 7, 2013
    #19
    I want to be able to select a specific tab, lets say tab 27 when i am on tab 1 2 3 whatever.
    I just want a button to send me to a tab, i can't explain it more specifically than that, I've been trying for 2 months now with no success.
     
  20. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #20
    Draw it and post it.
     
  21. Intelligent thread starter macrumors 6502a

    Intelligent

    Joined:
    Aug 7, 2013
    #21
    What do you mean Draw? I click a button and it sends me to a tab, think about it :confused:
     
  22. Dookieman, May 13, 2014
    Last edited: May 13, 2014

    Dookieman macrumors 6502

    Joined:
    Oct 12, 2009
    #22
    (I'm assuming English is not your primary language?)

    We need the following to effectively help you.

    -What language are you using?
    -Applescript or Objective-C?
    -Can you post a screen shot of your compiled app?
    -Can you post a screen shot of your code so we can see what you have so far and where we can help?

    We need to these to most effectively help you with your problem.

    Others have given advice on how to improve the over performance and layout of your app. You claim you don't care and want to do it your way. Why do you want to learn how to do things the wrong way?

    Also, stating "Help in Xcode" is very vague. Xcode is an IDE.

    Xcode itself can be very daunting since it is quite complex, and understanding how to use it and make effective code would be a better question for "Help in Xcode".
     
  23. Intelligent thread starter macrumors 6502a

    Intelligent

    Joined:
    Aug 7, 2013
    #23
    You are the only one that has said something about "help in Xcode".
    However, i dont see how it's the wrong way, they just said what i could do, not how to do it.
    In this app i am using objective-C.
    I have not done any coding yet i just want to know how to click a button so that i can get to a tab. Linking a button to a tab.
     
  24. Red Menace macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #24
    Unless you want a bunch of buttons, one plan would be to use a button to programmatically go to a particular tab by using something like NSTabView's selectTabViewItemAtIndex, which has already been mentioned.
     
  25. Intelligent thread starter macrumors 6502a

    Intelligent

    Joined:
    Aug 7, 2013
    #25
    I want to have a bunch of buttons.
     

Share This Page