ios - unrecognized selector sent to instance resignFirstResponder -


i'm using tpkeyboardavoiding in app hide move text fields when keyboard showing, i'm getting exception when try end editing text field. it's coming method in tpkeyboardavoiding:

- (void) touchesended:(nsset *)touches withevent:(uievent *)event {     uiview* view =[self tpkeyboardavoiding_findfirstresponderbeneathview:self];     nslog(@"%@",[view description]);     [view resignfirstresponder]; //this line gives exception     [super touchesended:touches withevent:event]; } 

i'm bit confused here. shouldn't uiviews respond resignfirstresponder? help.

full error:

2014-03-25 17:40:39.919 rysk[5553:70b] -[menuviewcontroller textfielddidbeginediting:]: unrecognized selector sent instance 0xb63c820 

not sure if have called [yourtextfield resignfirstresponder] as well. possible uitextfield (in code have provided) is not firstresponder @ point. suggest adjust code this:

- (void) touchesended:(nsset *)touches withevent:(uievent *)event {     uiview* view =[self tpkeyboardavoiding_findfirstresponderbeneathview:self];      if([view conformstoprotocol:@protocol(uitextfielddelegate)] || [view conformstoprotocol:@protocol(uitextviewdelegate)]) &&         [view isfirstresponder] && [view canresignfirstresponder])     {        [view resignfirstresponder];       }      [super touchesended:touches withevent:event]; } 

also, if using pods please make sure using latest version, because 1 using has in event:

- (void) touchesended:(nsset *)touches withevent:(uievent *)event {     [[self tpkeyboardavoiding_findfirstresponderbeneathview:self] resignfirstresponder];     [super touchesended:touches withevent:event]; } 

hope helps!


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -