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

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

    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默认选中第一行并实现点击第一行的效果)