2013-06-20 67 views

回答

1

只需调用方法selectRowAtIndexPath:动画:的scrollPosition:表格视图在加入细胞后,假定小区索引0被添加部分0的:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; 
[tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewRowAnimationTop] 
+0

您好,感谢快速回复。但我已经试过这个,并得到以下错误 ***由于未捕获的异常'NSRangeException',原因:' - [UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]:行(0)超出界限(0) 0)“。 另外,如果我用UITableViewScrollPositionNone替换UITableViewRowAnimationTop,那么它将在表中只有1条记录时选择顶行,然后选择每行第2行。 –

+0

@Harshal您需要将您的代码发布到添加新单元格的位置,以便我可以查看。 –

+0

if(self.isNewRecord)countOfLogbookRecords = [self.tableView_top numberOfRowsInSection:0] +1; [self createRecordWithKeyValue:logbookDictionary className:RECORD_LOGBOOK]; NSIndexPath * indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [self.tableView_top selectRowAtIndexPath:indexPath animated:NO scrollPosition:0]; } 这里是代码。我正在使用核心数据。 –

相关问题