Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AlertView does not disable Interactive Pop Gesture #66

Closed
guilhermearaujo opened this issue Feb 11, 2015 · 9 comments
Closed

AlertView does not disable Interactive Pop Gesture #66

guilhermearaujo opened this issue Feb 11, 2015 · 9 comments
Assignees

Comments

@guilhermearaujo
Copy link

When I show an alert which should not be cancellable by touching outside its view, I expect the user to be "blocked", restricted to one of the options I present him (using buttons in the alert).
I noticed, however, that if the alert is presented from a VC inside a UINavigationController, the pop gesture (swipe from left to go back) still works.

This is bad, in my case, for instance, because I show a Progress alert with a button to cancel the HTTP request I'm performing. If the view controller is dismissed prematurely, the request will still be processed in background, and its completion block will fail because the view controller is no longer available.

I suggest the interactive pop gesture to be disabled while the alert is visible.

@dogo dogo self-assigned this Feb 11, 2015
@dogo
Copy link
Owner

dogo commented Feb 11, 2015

Yep, @guilhermearaujo you are right, to disable the pop gesture I need access to the navigationController like this 👍
<VIEWCONTROLLER>.navigationController.interactivePopGestureRecognizer.enabled = NO;

The problem is: the viewController I get as a parameter can not have access to navigationController.
What we can do is: do a search looking for the navigationController or set it as an optional property

What you think about it?

@guilhermearaujo
Copy link
Author

What about this?

UINavigationController *navController = [<#ViewController#> navigationController];
if (navController != nil) {
    [[navController interactivePopGestureRecognizer] setEnabled:NO];
}

Then set it back to enabled once the alert is dismissed.

@dogo dogo closed this as completed in 0ab2a30 Feb 11, 2015
@dogo
Copy link
Owner

dogo commented Feb 11, 2015

@guilhermearaujo Yep, almost this.

Please test my fix 0ab2a30

@dogo dogo reopened this Feb 11, 2015
@guilhermearaujo
Copy link
Author

Your change will work if the view controller passed is embedded into a UINavigationController, however will still not work if the view controller is the UINavigationController.

@dogo
Copy link
Owner

dogo commented Feb 12, 2015

Seems fine in all my tests, could you please provide me an sample?

@guilhermearaujo
Copy link
Author

Here it goes: https://github.com/guilhermearaujo/SCLAlertView/commit/ff62b8cd21db1375ed06735bcd5f444c34e126ab

I've added a NavigationController and a previous view before your list of buttons to display the alerts.
Then I've changed the Error call to be presented on [self navigationController] instead of self.

Push any other button, and the swipe gesture is disabled. Push the error button and see what happens.

@dogo
Copy link
Owner

dogo commented Feb 13, 2015

Patched :D
Please test c4ebc99 .

and thanks

@guilhermearaujo
Copy link
Author

Perfect!

@dogo dogo closed this as completed Feb 13, 2015
@dogo
Copy link
Owner

dogo commented Feb 13, 2015

Official release 0.5.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants