简体   繁体   中英

Disallow pop segue to certain class

I've got a UINavigationController that can pop to multiple VC's. I want to disallow the 'slide to pop' slide animation if the VC to pop to is of a certain class. How do I do that?

Disabling the slide animation for the entire navigationcontroller can be done like this:

self.navigationController.interactivePopGestureRecognizer.enabled = NO;

But I want that only to be true if the destination is of a certain class.

I haven't tried this but the following should work:

UINavigationController has the interactivePopGestureRecognizer property.

In the viewDidAppear method of the view controller that you don't want to allow the "slide to pop", do:

self.navigationController.interactivePopGestureRecognizer.enabled = NO;

Then in the same view controller's viewDidDisappear method, call:

self.navigationController.interactivePopGestureRecognizer.enabled = YES;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM