objective c - UITextField in UITableView: setting the first responder view of the table but we don't know its type (cell/header/footer) -
i have uitextfield inside of uitableviewcell, , want detect when user begins typing inside of uitextfield. set uitextfields delegate, when code runs, warning 'setting first responder view of table don't know type (cell/header/footer)' , uitextfield delegate methods dont called. how can uitextfield methods called?
-(void)tableview:(id)view willdisplaycell:(uitableviewcell *)cell forrowatindexpath:(nsindexpath *)indexpath { if ((indexpath.section == 0) && (indexpath.row == 3)) { uitapgesturerecognizer *tap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(friendcelltapped)]; [tap setnumberoftapsrequired:1]; [cell addgesturerecognizer:tap]; } else if ((indexpath.section == 0) && (indexpath.row == 4)) { nslog(@"im called"); uitextfield *tagbox = [[uitextfield alloc] initwithframe:cgrectmake(50, 6, 225, 25)]; [tagbox setborderstyle:uitextborderstyleroundedrect]; [tagbox setreturnkeytype:uireturnkeydone]; tagbox.delegate = self; [cell addsubview:tagbox]; } else { %orig; } }
i've done before creating uitextfield
variable on uiviewcontroller
class , setting uitableviewcell's textfield in tableview:cellforrowatindexpath
. set delegate of uitextfield
variable in viewdidappear:
.
something this:
-(void)viewdidappear:(bool)animated { [super viewdidappear:animated]; self.thetextfield.delegate = self; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { //load custom cell self.thetextfield = mycustomcell.celltextfield; return mycustomcell; }
then uitextfielddelegate methods should called.
Comments
Post a Comment