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?
What you're describing is normal iOS behavior and not Model ViewController
specific. Entering or exiting ViewController
s using push and pop will also wait for transition to end before receiving touch events on the destination ViewController
.
A good solution to avoid this would be to present your ViewController
in a container inside the first ViewController
.
Showing 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.
For example:
- (IBAction)hideContainer:(id)sender {
[UIView animateWithDuration:0.4
delay:0.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^
{
self.container.alpha = 0;
}
completion:^(BOOL finished){}];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With