I want to set the default selected row by selectRow(at:animated:scrollPosition:)
. But the document said calling this method does not cause the delegate to receive a tableView(_:didSelectRowAt:)
message.
How to set the default selected row and call the tableView(_:didSelectRowAt:)
?
我只需要以编程方式调用tableView(_:didSelectRowAt:)
This will work for you.
tableView.delegate = self
In viewWillAppear() or after few milliseconds of viewDidLoad, call this:
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:)
after selectRow(at:animated:scrollPosition:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.