Home:ALL Converter>iOS: touch events are not sent to the next controller while a modal is dismissed

iOS: touch events are not sent to the next controller while a modal is dismissed

Ask Time:2014-01-10T19:58:40         Author:PJC

Json Formatter

In my Storyboard I defined a modal segue. The corresponding modal view is dismissed via a button and a simple:

- (IBAction)dismiss:(id)sender {
    [self dismissViewControllerAnimated:YES completion:^{
        return;
    }];   
}

Everything works but the thing is, while this transition is occurring, if the user taps in the view of the "next" controller (i.e. the one that will replace the modal), touch events are not captured by this controller until the transition completes entirely.

My chain of controllers is:

UINavigationController -> visibleViewController -> modal Controller

(but note that the modal Controller is actually presented by the navigationController - that's how it is setup by default in the Storyboard).

How can you make sure that as soon as the transition starts, touch events are sent to the next controller?

Author:PJC,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/21043787/ios-touch-events-are-not-sent-to-the-next-controller-while-a-modal-is-dismissed
Segev :

What you're describing is normal iOS behavior and not Model ViewController specific. Entering or exiting ViewControllers using push and pop will also wait for transition to end before receiving touch events on the destination ViewController.\n\nA good solution to avoid this would be to present your ViewController in a container inside the first ViewController. \nShowing and dismissing the ViewController are under your responsibility and will require a bit more code (for example playing with the alpha channel of the container) but will give you more control on who and when a view receives touch events.\n\nFor example:\n\n- (IBAction)hideContainer:(id)sender { \n\n [UIView animateWithDuration:0.4 \n delay:0.0 \n options:UIViewAnimationOptionAllowUserInteraction\n animations:^\n {\n self.container.alpha = 0;\n }\n completion:^(BOOL finished){}]; \n}\n",
2015-06-20T13:00:58
yy