繁体   English   中英

方法selectRow(at:animated:scrollPosition :)不调用tableView(_:didSelectRowAt :)

[英]The method selectRow(at:animated:scrollPosition:) doesn't call tableView(_:didSelectRowAt:)

我想通过selectRow(at:animated:scrollPosition:)设置默认的选定行。 但是文档说,调用此方法不会导致委托接收到tableView(_:didSelectRowAt:)消息。

如何设置默认的选定行并调用tableView(_:didSelectRowAt:)

我只需要以编程方式调用tableView(_:didSelectRowAt:)

这将为您工作。

tableView.delegate = self

在viewWillAppear()中或在viewDidLoad几毫秒后,调用此命令:

tableView.selectRow(at: <IndexPath?>, animated: <Bool>, scrollPosition: <UITableViewScrollPosition>)

在此处分享您的完整源代码,这样可以给您更好的建议。

您可以调用tableView(_:didSelectRowAt:)

selectRow(at:animated:scrollPosition:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM