UITableView 获取cell的内容
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChanged:)name:UITextViewTextDidChangeNotification object:nil];
#pragma mark 监听方法
- (void)textChanged:(NSNotification *)notification
{
if ([notification.object isKindOfClass:[UITextView class]]) {
UITextView * textview = notification.object;
if (textview) {
NSLog(@"notification-UITextView->%@",textview.text);
//获取改变了的textfield对应的NSIndexPath
//获取到对应的NSIndexPath就可以设置对应的数据源了
CGPoint point = [textview.superview convertPoint:textview.frame.origin toView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];
}
}
}
有个更好的替代方法
[cell.delBtn addTarget:self action:@selector(delEhr:event:)
forControlEvents:UIControlEventTouchUpInside];
-(void)delEhr:(UIButton*)sender event:(id)event{
NSSet *touches =[event allTouches];
UITouch *touch =[touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
NSIndexPath *indexPath= [self.tableView indexPathForRowAtPoint:currentTouchPosition];
if (indexPath!= nil)
{
NSLog(@"select %d",indexPath.row);
}
}