Reputation: 11
i just know to get indexpath button inside tableviewcell like this
CGPoint center= [sender center]; CGPoint rootViewPoint = [[sender superview] convertPoint:center toView:_tableView1]; NSIndexPath *indexPath = [_tableView1 indexPathForRowAtPoint:rootViewPoint]; NSLog(@"%@",indexPath);
but i need know about textfield thx for helping me guys!
Upvotes: 0
Views: 579
Reputation: 591
There is another method to get the index row!
In cellForRow do this:
textField.tag = indexPath.row;
In the textField method do this:
- (void)textFieldDidBeginEditing:(UITextField *)textField {
NSInteger row = textField.tag;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
}
Upvotes: 1
Reputation: 2496
To get the indexPath
of the cell in which the textfield is contained you need to do a couple of things.
viewController
class the delegate of the textField in the tableView's celltextFieldDidBeginEditing
method of textField's delegateProtocol
in your viewController
's class like this- (void)textFieldDidBeginEditing:(UITextField *)textField {
//Here you can you the same logic to find the indexPath of the cell like you use in case of a button.
}
Upvotes: 0