iOS tableview 默认选中效果实现

2017-05-16  本文已影响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];

}

上一篇 下一篇

猜你喜欢

热点阅读