ios7禁止默認划動返回

 self.navigationController.interactivePopGestureRecognizer.enabled = NO;ios

spa

在使用以前先要判斷是否ios7,否則會致使crash。而後建立一個本身的navigationController繼承UINavigationController。以後還要設置UINavigationControllerDelegate,這樣以上的方法才能觸發。最後就判斷要show出來的viewController是否須要支持划動返回了。

 

 

 

 - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animatedcode

{
     if ([ self respondsToSelector : @selector (interactivePopGestureRecognizer)]) {
         if (viewController .class == [ MyViewController class ])
         {
             self .interactivePopGestureRecognizer .enabled = NO ;
         } else {
             self .interactivePopGestureRecognizer .enabled = YES ;
         }
     }
}