2017-03-02 150 views
0

我想將默認選定行設置爲selectRow(at:animated:scrollPosition:)。但該文件稱調用此方法不會導致代理人收到一條tableView(_:didSelectRowAt:)消息。方法selectRow(at:animated:scrollPosition :)不會調用tableView(_:didSelectRowAt :)

如何設置默認選定行並調用tableView(_:didSelectRowAt:)

+0

你可以叫自己'的tableView(_:didSelectRowAt:)'。 – Larme

+0

重複請檢查http://stackoverflow.com/questions/2035061/select-tableview-row-programmatically – tspentzas

回答

0

我只需要調用tableView(_:didSelectRowAt:)編程

0

這會爲你工作。

tableView.delegate = self 

在viewWillAppear中()或viewDidLoad中的幾毫秒後,稱此:

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

分享你在這裏完整的源代碼,這樣可以給你更好的建議。

0

您可以撥打tableView(_:didSelectRowAt:)

selectRow(at:animated:scrollPosition:)

相關問題