加载视图时,tableview 将选择第一行并触发 didselectatrow 方法来执行某些操作。我只知道如何选择第一行,但它不会同时触发 didselectatrow 方法 告诉我如何这样做
问问题
1685 次
1 回答
5
您可以手动调用该方法viewDidLoad
:
- (void)viewDidLoad {
[super viewDidLoad];
// select the first row
NSIndexPath *firstRowPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView selectRowAtIndexPath:firstRowPath animated:NO scrollPosition: UITableViewScrollPositionNone];
[self tableView:self.tableView didSelectRowAtIndexPath:firstRowPath];
}
于 2013-05-10T02:57:09.680 回答