ios - Get text from text field on Table cell -
i have custom cell uitextfield
. should set delegate
, in custom cell class or in view's class ?
i trying in both, no results. set delegate storyboard.
here did:
-(void)textviewshouldreturn:(uitextfield *)textfield { if ([textfield.text isequaltostring:@""]){ return; } uialertview *helloearthinputalert = [[uialertview alloc] initwithtitle:@"name!" message:[nsstring stringwithformat:@"message: %@", textfield.text] delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [helloearthinputalert show]; }
but part working if put cell.notetextfield.delegate=self :
-(bool)textfieldshouldbeginediting:(uitextfield *)textfield{ self.tableview.frame=cgrectmake(self.tableview.frame.origin.x, self.tableview.frame.origin.y-30, self.tableview.frame.size.width, self.tableview.frame.size.height); return yes; }
add delegate in custom cell's class. not forget implement protocols
// mycell.h @interface mycell : uitableviewcell <uitextfielddelegate> // ... // mycell.m -(void)autoconfigurecell // method added configure cell, can in "-(void)layoutsubviews" { // ... mytextfield.delegate = self; // ... } -(bool)textfieldshouldreturn:(uitextfield *)textfield // <-- bool { // stuff return yes; }
Comments
Post a Comment