ios - Dismissing keyboard from textfield inside tableviewcell -
this question has answer here:
- how dismiss keyboard ios programmatically 17 answers
i have custom tableviewcell has textfield inside.
how dismiss keyboard when tap place outside textfields?
do have through cells use [cell.textview resignfirstresponder]
?
try code :
-(void)touchesbegan:(nsset *)touches withevent:(uievent *)event{ [self.view endediting:yes]; }
or can add tap gesture recognizer :
uitapgesturerecognizer *tapper; - (void)viewdidload { [super viewdidload]; tapper = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(handlesingletap:)]; tapper.cancelstouchesinview = no; [self.view addgesturerecognizer:tapper]; } - (void)handlesingletap:(uitapgesturerecognizer *) sender { [self.view endediting:yes]; }
Comments
Post a Comment