iphone - managing keyboard in ios for number of textfields -
everything fine me except 1 case. when begin editing textfield, keyboard shown: method getting called, without resigning first 1 if edit next textfield, method not getting called.
- (void)registerforkeyboardnotifications { [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(keyboardwasshown:) name:uikeyboarddidshownotification object:nil]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(keyboardwillbehidden:) name:uikeyboardwillhidenotification object:nil]; } -(void)keyboardwasshown:(nsnotification*)anotification { nsdictionary* info = [anotification userinfo]; cgsize kbsize = [[info objectforkey:uikeyboardframebeginuserinfokey] cgrectvalue].size; uiedgeinsets contentinsets = uiedgeinsetsmake(0.0, 0.0, kbsize.height, 0.0); testscroll.contentinset = contentinsets; testscroll.scrollindicatorinsets = contentinsets; cgrect arect = self.view.bounds; cgpoint activepoint= [active.superview convertpoint:active.frame.origin toview:nil]; if (!cgrectcontainspoint(arect, activepoint) ) { cgpoint scrollpoint = cgpointmake(0.0, active.frame.origin.y+active.frame.size.height-kbsize.height+100);// here active particular textfields , changing in begin editing method. [testscroll setcontentoffset:scrollpoint animated:yes]; }
here problem though switching between 2 text fields scrollview has set particular offset.
thank you.
Comments
Post a Comment