Implementing the Next button on the keyboard

Discussion in 'iOS Programming' started by Farani, Sep 13, 2008.

  1. Farani macrumors 6502

    Joined:
    Oct 21, 2007
    #1
    I have a table populated with UItextfield objects and I'd like to implement the "Next" button on the keyboard so that when it is pressed the next textField in the table goes into editing mode. I've tried everything I can think of and I haven't been able to find anything in the documentation thus far. Any ideas? Thanks.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    So you have set the return key type to UIReturnKeyNext right? Does the UITextField delegate method

    Code:
    - (BOOL)textFieldShouldReturn:(UITextField *)textField
    
    not get called when the "return" (really Next) button gets pressed? Assuming it does (it should) just return NO and do what you want to do instead...
     
  3. Farani thread starter macrumors 6502

    Joined:
    Oct 21, 2007
    #3
    It does get called. My problem isn't that, it's that I don't know how to programmatically start editing on another text field. I know where I need to implement this, I just don't know how to do it.

    EDIT: Thank you so much for the response!
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Sorry. You didn't say that. This is a perfect example of why people should post code.

    Assuming you have a reference to the UITextField you wish to start editing in you should simply be able to send it a becomeFirstResponder message. From the UIResponder documentation for becomeFirstResponder:

    "Sending this message to a view object, for example a UITextField instance, will cause it to become the first responder and begin editing."

    It really is all in the documentation...
     
  5. Farani thread starter macrumors 6502

    Joined:
    Oct 21, 2007
    #5
    Sorry. I kept my question broad initially because I thought maybe there was an easier way. I really didn't want to post here; I assumed it was in the doc and I was just missing it. Sorry for the bother and thank you for taking the time to respond. I really appreciate it.

    - Ryan

    PS Do you own a Lotus?
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    No bother at all :) Sometimes having learnt desktop Cocoa first helps as this is basically the same as there.

    And yes, I have a S2 Elise 111S :D
     
  7. Farani thread starter macrumors 6502

    Joined:
    Oct 21, 2007
    #7
    I understand. I essentially learned what I needed to of desktop Cocoa and then I dove into the iPhone; it was more due to time constraints. I'm a college student and the summer ran out.

    Such a beautiful car! The Exige S in the states here is my dream car! I'm currently selling my car and could have picked up a Lotus Elise for cheap but it meant also buying a second car for the winter, so it's just not practical for me while I'm in school. I decided to get an 08 STI instead. But someday I will own a Lotus! I am very jealous :)!
     

Share This Page