Dismissing The Keyboard

  • Hellow,
    I'm using the numberpad for entering text in the textFields in my iPhone app which is fine, but for some reason I've resigned firstResponder to all the textFields so I can dismiss the keyboard when I press the calculate button, but when I press said button, the keyboard just stays on the screen.
    Does anyone know what is the best way of dismissing the keyboard?  I preferably want to dismiss the keyboard for whichever of the 3 textFields I'm writing in.  Also, I've called my textFields txt1, txt2 and txt3 to make it easier, but I had to put an _ character when I wrote the resignFirstResponder lines for the app to even build and run.
    Thanks for any help/suggestions,
    Harmony.
  • On Wed, May 22, 2013 at 1:34 PM, Harmony Neil <harmony.neil...> wrote:

    > Does anyone know what is the best way of dismissing the keyboard?
    > I preferably want to dismiss the keyboard for whichever of the 3 textFields I'm writing
    > in.

    Hello,

    Give UIView's endEditing: method a try. Here is the doc (shortened
    with google since Apple's doc URL are kinda messy):
    http://goo.gl/Cs2Pw

    You'd basically call it on the UIView containing these text fields.

    PS: objc-language should not be used for email messages like this.
    cocoa-dev is fine.

    Andreas
  • Take a look at [UIView endEditing].

    On May 22, 2013, at 4:34 AM, Harmony Neil <harmony.neil...> wrote:

    > I preferably want to dismiss the keyboard for whichever of the 3 textFields I'm writing in.
  • Do you also have the text field hooked up to File Owner's delegate?
    That needs to be done to dismiss KB.

    On May 22, 2013, at 7:34 AM, Harmony Neil <harmony.neil...> wrote:

    > Hellow,
    > I'm using the numberpad for entering text in the textFields in my iPhone app which is fine, but for some reason I've resigned firstResponder to all the textFields so I can dismiss the keyboard when I press the calculate button, but when I press said button, the keyboard just stays on the screen.
    > Does anyone know what is the best way of dismissing the keyboard?  I preferably want to dismiss the keyboard for whichever of the 3 textFields I'm writing in.  Also, I've called my textFields txt1, txt2 and txt3 to make it easier, but I had to put an _ character when I wrote the resignFirstResponder lines for the app to even build and run.
    > Thanks for any help/suggestions,
    > Harmony.
  • This is what I use when using a UISearchBar in iOS.

    -(void)searchBarSearchButtonClicked:(UISearchBar *)aSearchBar {
        [aSearchBar resignFirstResponder];
    }

    By using the _ char in front of your var, it looks like you're talking directly to the private instance.  If you have a textfield called txt1, does it work if you try this:

    [self.txt1 resignFirstResponder];

    ??

    Did you forget to synthesize your property?  I actually ran into that today in Xcode 4.6.1 but only because I had started to @synthesize some vars and I think Xcode was trying to predict how I wanted the class vars to be scoped.

    On May 22, 2013, at 7:45 PM, Marcus Staloff wrote:

    >
    > Do you also have the text field hooked up to File Owner's delegate?
    > That needs to be done to dismiss KB.
    >
    > On May 22, 2013, at 7:34 AM, Harmony Neil <harmony.neil...> wrote:
    >
    >> Hellow,
    >> I'm using the numberpad for entering text in the textFields in my iPhone app which is fine, but for some reason I've resigned firstResponder to all the textFields so I can dismiss the keyboard when I press the calculate button, but when I press said button, the keyboard just stays on the screen.
    >> Does anyone know what is the best way of dismissing the keyboard?  I preferably want to dismiss the keyboard for whichever of the 3 textFields I'm writing in.  Also, I've called my textFields txt1, txt2 and txt3 to make it easier, but I had to put an _ character when I wrote the resignFirstResponder lines for the app to even build and run.
    >> Thanks for any help/suggestions,
    >> Harmony.

previous month may 2013 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today