我想將默認選定行設置爲selectRow(at:animated:scrollPosition:)
。但該文件稱調用此方法不會導致代理人收到一條tableView(_:didSelectRowAt:)
消息。方法selectRow(at:animated:scrollPosition :)不會調用tableView(_:didSelectRowAt :)
如何設置默認選定行並調用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://stackoverflow.com/questions/2035061/select-tableview-row-programmatically – tspentzas