边缘侧滑

一 ,在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;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 前言:ios7开始 苹果增加了页面 右滑返回的效果;具体的是以UINavigationController为容器的...
    iPhone阅读 3,784评论 2 3
  • ios7开始 苹果增加了页面 右滑返回的效果;具体的是以UINavigationController为容器的Vie...
    Q6尐漒阅读 1,346评论 0 0
  • 第一步, 签代理 @interface NAFirstBookStoreViewController () 第二步...
    NateLam阅读 1,565评论 0 2
  • 作为一个大学老师,还是毛概老师。我不明白为什么会有这样的人,无限贬低自己的民族自己的国家自己的领导人,觉得自己的所...
    小姐姐w阅读 315评论 0 0
  • 通过这两天与上四年级的表妹的全天候接触,更加深刻的认识和理解了这句话: “你绝不可能改变一个人,但可以影响他” 第...
    窗外_6ac6阅读 450评论 0 1