[英]The method selectRow(at:animated:scrollPosition:) doesn't call tableView(_:didSelectRowAt:)
I want to set the default selected row by selectRow(at:animated:scrollPosition:)
. 我想通过selectRow(at:animated:scrollPosition:)
设置默认的选定行。 But the document said calling this method does not cause the delegate to receive a tableView(_:didSelectRowAt:)
message. 但是文档说,调用此方法不会导致委托接收到tableView(_:didSelectRowAt:)
消息。
How to set the default selected row and call the tableView(_:didSelectRowAt:)
? 如何设置默认的选定行并调用tableView(_:didSelectRowAt:)
?
我只需要以编程方式调用tableView(_:didSelectRowAt:)
This will work for you. 这将为您工作。
tableView.delegate = self
In viewWillAppear() or after few milliseconds of viewDidLoad, call this: 在viewWillAppear()中或在viewDidLoad几毫秒后,调用此命令:
tableView.selectRow(at: <IndexPath?>, animated: <Bool>, scrollPosition: <UITableViewScrollPosition>)
Share you full source code here, so can give you better suggestion. 在此处分享您的完整源代码,这样可以给您更好的建议。
You can call tableView(_:didSelectRowAt:)
您可以调用tableView(_:didSelectRowAt:)
after selectRow(at:animated:scrollPosition:)
在selectRow(at:animated:scrollPosition:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.