美文网首页ios专题iOS开发
tableview默认选中第一行显示选中效果

tableview默认选中第一行显示选中效果

作者: HeavenWong | 来源:发表于2016-07-21 18:19 被阅读432次
// 初始化文字的方法
-(void)initialText
{
    if (_isInitial == NO) {
        // 两句代码缺一不可
        [self.table_view selectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
       [self tableView:self.table_view didSelectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];//实现点击第一行所调用的方法
        _isInitial = YES;
    }
}

相关文章

网友评论

    本文标题:tableview默认选中第一行显示选中效果

    本文链接:https://www.haomeiwen.com/subject/htsvdttx.html