如何在加载tableView之后默认选中第一行。

这个东西写在重用池里面 

NSIndexPath *first = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView selectRowAtIndexPath:first animated:YES scrollPosition:UITableViewScrollPositionNone];

当然 如果tableView滚动了 还是会选择第一行 所以 

定义一个NSInteger

NSInteger row = [NSIndexPaht row]; 这样来记录点击了第几行

然后在重用池里面加判断

if (self.row > 0) {

              

        }

        else

        {

        NSIndexPath *first = [NSIndexPath indexPathForRow:0 inSection:0];

        [self.leftTableView selectRowAtIndexPath:first animated:NO scrollPosition:UITableViewScrollPositionNone];

        }

这样就行了

 

posted @ 2015-03-19 21:03  Mr.Greg  阅读(589)  评论(0编辑  收藏  举报