Advertisement

Accelerate/Force a Segue in iOS 8.1

The issue here is that I had a SplitViewController design, where one of the MasterViewController (tableView) cells triggered a modal segue to a viewController that was presented to the user earlier in the flow.

Everytime the user tapped the target cell from any other menu item (also in the tableView of MasterViewController), it worked great.

Except…

 … whenever I tapped the target cell from the default frame it seemed to requre a second tap to complete the segue. Usually it would dismiss the view and leave the gray detail view with nothing coming. And, sometimes it would suddenly modally present the target viewController. 

Other Behaviors: Most often it would hang and not complete the desired viewController presentation unless tapped a second time. (Who wants to accept that?) Here’s the answer that worked for me:

            UINavigationController *detailNavigationController = [[[self splitViewController] viewControllers] objectAtIndex:1];

            indexPath = [NSIndexPathindexPathForRow:self.lastCellIndexinSection:0];

            dispatch_async(dispatch_get_main_queue(), ^ {

                [detailNavigationController performSegueWithIdentifier:@”showAreaSelection” sender:indexPath];

            });

I got this from this StackOverflow answer.