resignFirstResponder for UITextView

Discussion in 'Public Game Developers Forum' started by kohjingyu, Jul 10, 2009.

  1. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    Hey guys,
    I was wondering if it was possible to implement a method which resigns the FirstResponder of the UITextView when you press the done button.
     
  2. rdklein

    rdklein Well-Known Member

    Apr 3, 2009
    384
    0
    0
    sw developer, tv producer, hw developer (microcodi
    Munich
    yes of course:

    just call the method when the button is pressed, link the uitextviewptr to the text view .

    ...
    IBOutlet UITextView *uitextviewptr ;
    @property (retain,nonatomic) IBOutlet UITextView *uitextviewptr ;

    ...
    @synthesize uitextviewptr ;

    -(IBAction) do_done: (id)sender
    {
    [uitextviewptr resignFirstResponder ];
    }
     
  3. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    Hmm, I'm pretty sure that method is for UIButtons. What I want is when you press the Done key on the keyboard.
     
  4. Fu3lRac3r

    Fu3lRac3r Active Member

    Jun 7, 2009
    33
    0
    0
    Web Design and iPhone Development
    England
    Just connect the action to the DidEndOnExit Event and it should work fine xD
     
  5. rdklein

    rdklein Well-Known Member

    Apr 3, 2009
    384
    0
    0
    sw developer, tv producer, hw developer (microcodi
    Munich
    And in this case you only need:


    -(IBAction) do_done: (id)sender
    {
    [sender resignFirstResponder ];
    }
     
  6. drunknbass

    drunknbass Well-Known Member

    Nov 8, 2008
    128
    0
    0
    can i ask why? text view is usually for multiline text and return key has a purpose to insert line breaks. if you are not doing multiline scrolling text you dont need a textVIEW.

    and if you use uitextfield you can implement its delegate method for when the return key was pressed.
     
  7. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    Okay, then does anyone know how to make a UITextfield extend itself as the text becomes longer like in the text application? I've seen a tutorial for it somewhere but can't seem to find it...
     

Share This Page