加载UITableView
时,我希望选择唯一部分中的唯一行,以便在用户加载didSelectRowAtIndexPath
时立即执行UITableView
中的代码。我已经尝试了下面的代码,但没有执行didSelectRowAtIndexPath
部分中的代码。有什么想法吗?
NSIndexPath *indexedPath = [NSIndexPath indexPathForRow:0 inSection:0];
[tableView selectRowAtIndexPath:indexedPath animated:YES scrollPosition: UITableViewScrollPositionNone];
最佳答案
使用此代码。加载视图时,它将自动调用didSelectRowAtIndexPath
。
[self tableView:tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
关于ios - UITableView自动选择行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16215004/