在网上找到的其他方法都不可用,这个方法比较推荐
//默认选中第一行,并执行点击事件
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];
}
网友评论