相关疑难解决方法(0)

如何在iOS 7上的UINavigationController中禁用后滑动手势

在iOS 7中,Apple添加了一个新的默认导航行为.您可以从屏幕的左边缘滑动以返回导航堆栈.但在我的应用程序中,此行为与我的自定义左菜单冲突.那么,是否可以在UINavigationController中禁用这个新手势?

objective-c uinavigationcontroller uigesturerecognizer ios ios7

320
推荐指数
10
解决办法
14万
查看次数

如何在iOS 7中仅针对一个视图禁用后退手势

我正在尝试使用以下代码集为视图控制器禁用后退手势.

FirstViewController.m,我正在设置代表interactivePopGestureRecognizer

- (void) viewWillLoad {

    // Other stuff..
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
}
Run Code Online (Sandbox Code Playgroud)

然后实现该<UIGestureRecognizerDelegate>方法并返回NO.

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {

     return NO;
}
Run Code Online (Sandbox Code Playgroud)

在dealloc中,我将委托设置为nil.(我已在某处读过,在iOS 7中,您必须手动将委托设置为nil)

- (void)dealloc {

    self.navigationController.delegate = nil;
    self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
Run Code Online (Sandbox Code Playgroud)

这适用于FirstViewController.但是,当我推动SecondViewController这个时,手势也不起作用.如何才能在FirstViewController中禁用手势?

此外,当我弹出FirstViewControllerRootViewController然后尝试FirstViewController再次推送时,我得到对象解除分配错误:

[FirstViewController gestureRecognizer:shouldReceiveTouch:]: message sent to deallocated instance 0x14ed0280
Run Code Online (Sandbox Code Playgroud)

为什么除了将委托设置为nil之外我还需要做什么?或者我把它放在错误的地方?

back gesture ios7

5
推荐指数
2
解决办法
7958
查看次数