簡體   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