iOS UITableView 默认选择某行的方法

来源:互联网 发布:mysql与sqlserver区别 编辑:程序博客网 时间:2024/06/05 11:17

// 方法一 // 默认选中行,放在 reloadData 后NSIndexPath *ip=[NSIndexPath indexPathForRow:0 inSection:0];[tableView selectRowAtIndexPath:ip animated:YES scrollPosition:UITableViewScrollPositionBottom];// 方法二:NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];if ([myTableView.delegate respondsToSelector:@selector(tableView:willSelectRowAtIndexPath:)]) {    [myTableView.delegate tableView:self.tableView willSelectRowAtIndexPath:indexPath];} [myTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition: UITableViewScrollPositionNone];  if ([myTableView.delegate respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)]) {    [myTableView.delegate tableView:self.tableView didSelectRowAtIndexPath:indexPath];}




原文转自:http://blog.csdn.net/hanrovey/article/details/52170655
原创粉丝点击