方法selectRow(at:animated:scrollPosition :)不会调用tableView(_:didSelectRowAt :)
问题描述:
我想将默认选定行设置为selectRow(at:animated:scrollPosition:)
。但该文件称调用此方法不会导致代理人收到一条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:)
你可以叫自己'的tableView(_:didSelectRowAt:)'。 – Larme
重复请检查http://*.com/questions/2035061/select-tableview-row-programmatically – tspentzas