简体   繁体   English

iPhone 中的表格视图单元格选择

[英]tableview cell selection in iPhone

I am getting tableview cell as not selected when i scroll the tableview either in up and down direction.当我向上和向下滚动表格视图时,我得到的表格视图单元格未被选中。 How should i use following method in code?我应该如何在代码中使用以下方法?

[tableview selectRowAtIndexPath:animated:scrollPosition];

How should i use following method in code?我应该如何在代码中使用以下方法?

[tableview selectRowAtIndexPath:animated:scrollPosition];

Example : Add a new cell on the tableview and scroll the table up to added cell added:示例:在 tableview 上添加一个新单元格并将表格向上滚动到添加的单元格:

NSArray *indexPaths = [NSArray arrayWithObjects: [NSIndexPath indexPathForRow:[self.yourDataSource count]-1 inSection:0],nil];
[self.myTableView beginUpdates];
[self.myTableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationTop];
[self.myTableView endUpdates];
[self.myTableView scrollToRowAtIndexPath:indexPaths atScrollPosition:UITableViewScrollPositionTop animated:YES];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM