边缘侧滑

一 ,在iOS7.0之后添加了边缘滑动返回,如果在被push的控制器设置了自定义导航条或者自定义左button的时候会失效,通过这句话可以解决

:self.navigationController.interactivePopGestureRecognizer.delegate = self

并设置代理:UIGestureRecognizerDelegate

二 ,屏蔽系统自带滑动返回

self.navigationController.interactivePopGestureRecognizer.enabled = NO;

三 ,如何设置整个页面滑动返回?

1 获取边缘滑动返回对象

id obj = self.navigationController.interactivePopGestureRecognizer.delegate;

2 调用全屏滑动手势

UIPanGestureRecognizer *gesture= [[UIPanGestureRecognizer alloc] initWithTarget:obj action:@selector(handleNavigationTransition:)];

3 设置代理 添加手势

gesture.delegate = self;

[self.view addGestureRecognizer: gesture];

gesture.delegate = self;

[self.view addGestureRecognizer: gesture];

四。UIGestureRecognizerDelegate

// called when a gesture recognizer attempts to transition out of UIGestureRecognizerStatePossible. returning NO causes it to transition to UIGestureRecognizerStateFailed

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer;

// called when the recognition of one of gestureRecognizer or otherGestureRecognizer would be blocked by the other

// return YES to allow both to recognize simultaneously. the default implementation returns NO (by default no two gestures can be recognized simultaneously)

//

// note: returning YES is guaranteed to allow simultaneous recognition. returning NO is not guaranteed to prevent simultaneous recognition, as the other gesture's delegate may return YES

- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer;

// called once per attempt to recognize, so failure requirements can be determined lazily and may be set up between recognizers across view hierarchies

// return YES to set up a dynamic failure requirement between gestureRecognizer and otherGestureRecognizer

//

// note: returning YES is guaranteed to set up the failure requirement. returning NO does not guarantee that there will not be a failure requirement as the other gesture's counterpart delegate or subclass methods may return YES

- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizerNS_AVAILABLE_IOS(7_0);

- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizerNS_AVAILABLE_IOS(7_0);

// called before touchesBegan:withEvent: is called on the gesture recognizer for a new touch. return NO to prevent the gesture recognizer from seeing this touch

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

// called before pressesBegan:withEvent: is called on the gesture recognizer for a new press. return NO to prevent the gesture recognizer from seeing this press

- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldReceivePress:(UIPress*)press;

你可能感兴趣的:(边缘侧滑)