美文网首页
iOS tableview 默认选中效果实现

iOS tableview 默认选中效果实现

作者: 小泗泗 | 来源:发表于2017-05-16 10:42 被阅读0次

在网上找到的其他方法都不可用,这个方法比较推荐

//默认选中第一行,并执行点击事件

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

[tableview selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];

if ([tableview.delegate respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)]) {

[tableview.delegate tableView:tableview didSelectRowAtIndexPath:indexPath];

}

相关文章

网友评论

      本文标题:iOS tableview 默认选中效果实现

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