Ios UITableViewCell中的UITextView
您可以看到,当我在TableView的textView中插入7行时,该方法可以工作7次 然后,NSLog向我显示:Ios UITableViewCell中的UITextView,ios,objective-c,uitableview,uitextview,Ios,Objective C,Uitableview,Uitextview,您可以看到,当我在TableView的textView中插入7行时,该方法可以工作7次 然后,NSLog向我显示: - (void)textViewDidChange:(UITextView *)textView { CGPoint pos = [textView convertPoint:CGPointZero toView:self.editTableView]; NSIndexPath *indexPath = [self.editTableView indexPathFo
- (void)textViewDidChange:(UITextView *)textView
{
CGPoint pos = [textView convertPoint:CGPointZero toView:self.editTableView];
NSIndexPath *indexPath = [self.editTableView indexPathForRowAtPoint:pos];
NSLog(@"indexpath %@", indexPath);
AHAttribute *attribute = self.schedule.attributes[indexPath.row];
attribute.value = textView.text;
NSLog(@"changed Attribute textView %@", attribute.value);
}
所以我改变了我的代码:
indexPath {length = 2, path = 4 - 0}
changed Attribute textView (newline)
indexPath {length = 2, path = 4 - 0}
changed Attribute textView (newline)
(newline)
indexPath {length = 2, path = 4 - 0}
changed Attribute textView (newline)
(newline)
(newline)
indexPath {length = 2, path = 4 - 0}
changed Attribute textView (newline)
(newline)
(newline)
(newline)
indexPath {length = 2, path = 4 - 0}
changed Attribute textView (newline)
(newline)
(newline)
(newline)
(newline)
indexPath {length = 2, path = 4 - 0}
changed Attribute textView (newline)
(newline)
(newline)
(newline)
(newline)
(newline)
indexPath {length = 2, path = 3 - 1}
-error code...-
然后,修改后的代码向我展示了一个我想要的indexPath。
但为什么第一个代码会显示另一个indexath?如果您能帮助我,我将不胜感激。您的问题是什么?在哪里添加textView?cell.contentView或cell.NANNAV,cell.contentViewBhumeshwer-katre,第一个代码显示另一个indexPath,但第二个代码始终显示一个indexPath。我不明白为什么第一个代码显示另一个索引路径可能是您的问题标题错误,它应该是UITableViewCell中的
UITextView
对吗?
- (void)textViewDidChange:(UITextView *)textView
{
UITableViewCell *cell = [[[textView superview] superview] superview];
NSIndexPath *indexPath = [self.editTableView indexPathForCell:cell];
NSLog(@"indexpath %@", indexPath);
AHAttribute *attribute = self.schedule.attributes[indexPath.row];
attribute.value = textView.text;
NSLog(@"changed Attribute textView %@", attribute.value);
}