美文网首页iOS
iOS 设置tableview默认选中第一行并实现点击第一行的效

iOS 设置tableview默认选中第一行并实现点击第一行的效

作者: anny_4243 | 来源:发表于2016-12-09 14:57 被阅读344次

//如果有数据,默认选中第一行并请求第一行的数据

    if(self.tableViewData.count>0)
    {
        [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];//设置选中第一行
        [self tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];//实现点击第一行所调用的方法
    }

相关文章

网友评论

    本文标题:iOS 设置tableview默认选中第一行并实现点击第一行的效

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