怎样让程序第一次加载的时候默认选中TableView的第一行?

使tableview在界面启动后定位在x行
在viewDidLoad中加入以下代码
NSIndexPath *idxPath = [NSIndexPath indexPathForRow:x inSection:0];
[self.tableView scrollToRowAtIndexPath:idxPath
atScrollPosition:UITableViewScrollPositionMiddle
animated:NO];

 

首先选择行数你会的吧?selectRowAtIndexes:
滚动的话tableview的superview时scrollview,scrollview可以滚动到某个position
那么就要计算这个position
position = table row height * index

posted @ 2015-12-24 09:30  Bo-tree  阅读(135)  评论(0)    收藏  举报