objective c - Keyboard appearing briefly when popping viewcontroller iOS -


i'm experimenting issue numeric pad when popping current uiviewcontroller uinavigationcontroller.

in current uiviewcontroller. have few uitextfield , "save" button in uinavigationbar. expected behavior follows:

when user taps "save", keyboard must hide , network operation performed. in callback, uialertview shown. when user dismisses uialertview, notification raises , current uiviewcontroller performs

[self.navigationcontroller popviewcontrolleranimated:yes]; 

the thing is, if "save" pressed keyboard still showing, after performing popviewcontrolleranimated, keyboard appears briefly , left right (as if visible in previous uiviewcontroller).

i've tried

[mytextfield resignfirstresponder] 

when user taps "save", when user dismisses uialertview, , in

viewwilldisappear  

method. other answers suggest using

[self.view endediting:yes]; 

but doesn't work either.

if use regular keyboard trivial override

- (bool)textfieldshouldreturn:(uitextfield *)textfield {     [textfield resignfirstresponder];      return yes; } 

to hide when user taps "return", "done", etc. being numeric pad doesn't allow show "finish" button.

i'd appreciate help, thank time

try this:

set text field delegate , return type done , pad numeric pad.

  _textfield.delegate = self; _textfield.keyboardtype = uikeyboardtypedecimalpad; [_textfield setreturnkeytype:uireturnkeydone]; 

and add buttons keyboard:

    -(void)addbuttonstokeyboard {     uitoolbar* keyboarddonebuttonview = [[uitoolbar alloc] init];     [keyboarddonebuttonview sizetofit];       uibarbuttonitem* donebutton = [[uibarbuttonitem alloc] initwithtitle:nslocalizedstring(@"done", nil)                                                                    style:uibarbuttonitemstyledone target:self                                                                   action:@selector(kbdoneaction:)];      uibarbuttonitem* seperatoritem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:self action:nil];       uibarbuttonitem* cancelbutton = [[uibarbuttonitem alloc] initwithtitle:nslocalizedstring(@"cancel", nil)                                                                      style:uibarbuttonitemstyleplain target:self                                                                     action:@selector(kbcancelaction:)];       [keyboarddonebuttonview setitems:[nsarray arraywithobjects:cancelbutton,seperatoritem, donebutton, nil]];     _textfield.inputaccessoryview = keyboarddonebuttonview; } 

and hide keyboard:

    - (bool)textfieldshouldreturn:(uitextfield *)textfield {     [textfield resignfirstresponder];     return yes; } 

and done action method is:

    -(void)kbdoneaction:(id)sender {     [_textfield resignfirstresponder]; } 

and cancel action method is:

    -(void)kbcancelaction:(id)sender { [_textfield resignfirstresponder];     } 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -