gpt4 book ai didi

ios - 调用 TableView :didSelectRow:AtIndexPath in viewDidLoad

转载 作者:行者123 更新时间:2023-11-28 19:21:42 25 4
gpt4 key购买 nike

在 View 加载后,我必须在我的 UITableView 中选择一行。

所以我做了:

 [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];

这工作正常并且行被选中,但是我还希望调用 TableView:didSelectRow:AtIndexPath 方法,但现在不是这种情况。

有什么想法吗?

谢谢!

最佳答案

因为您知道要选择的行,所以您可以直接调用 tableView:didSelectRowAtIndexPath 中调用的方法。或者您可以自己调用 tableView:didSelectRowAtIndexPath:

NSIndexPath *initialIndex = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView selectRowAtIndexPath:initialIndex
animated:YES
scrollPosition:UITableViewScrollPositionTop];
[self tableView:self.tableView didSelectRowAtIndexPath:initialIndex];

关于ios - 调用 TableView :didSelectRow:AtIndexPath in viewDidLoad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8413301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com