In the main view of my app I have a table view and two prototype cells. I have configured the segues for each cell using the storyboard. In the view controller I override pr
Also worth moving the code if any from viewWillAppear to viewDidAppear
I checked your project. And while I also couldn't find anything else, I also suspect that it's a problem with threading.
I managed to fix the problem by implementing a delegate for the tableview and present the new controller in code:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let destination = storyboard?.instantiateViewControllerWithIdentifier("BuilderToysListViewController") as! BuilderToysListViewController
destination.botsRepository = botsRepository!
destination.builder = builders[builderIds[indexPath.row]]
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.presentViewController(destination, animated: true) { () -> Void in
}
})
}
Notice you have the set the view controller storyboard id: BuilderToysListViewController and also set the tableview delegate. Don't forget to remove the segues.
At the end to dissmis the view in the new view controller use this code:
@IBAction func backButton(sender: AnyObject)
{
dismissViewControllerAnimated(true, completion: { () -> Void in
})
// performSegueWithIdentifier("segueToysByBuilder", sender: nil)
}
This would allow you to properly close the view instead of wrongly creating a new one.
I was able to solve this for iOS 13 with Swift 5 by implementing the following:
DispatchQueue.main.async {
self.performSegue(withIdentifier: "YOURSEGUEID", sender: nil)
}
inside of
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {}
final result
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
DispatchQueue.main.async {
self.performSegue(withIdentifier: "YOURSEGUEID", sender: nil)
}
}
Hard to say unless you post your code that is responding to the tap on the cell and presenting the new view controller.
One common cause of long delays in UI changes (or having the UI change never happen) is trying to make UI changes from a background thread. Is it possible that your code that is invoking the segue is running on a different thread? You can tell this easily by setting a breakpoint on that code and observing the thread number when it breaks. If the thread number is 0 you're running on the main thread. If it's some other thread number, that's your problem.