interactivePopGestureRecognizer返回时消息传递
2016-04-08 10:47
525 查看
1、interactivePopGestureRecognizer是UISreenEdgePanGestureRecognizer的子类。
2. 当使用手势,返回时要监听是否真正返回,然后添加相应的消息传递。
首先想到是通过手势delegate的监听来完成。
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer。发现手势每次都会触发此方法。无法判断是否成功返回。
然后想到了用navigationController的delegate来监听。果然能达到想要效果
#pragma mark - UINavigationControllerDelegate
但,我在更改NavigationControllerDelegate时想要保存之前的<UINavigationControllerDelegate>,以便返回后再将代理更改回去。
我是把代理更改放到
里解决的,但似乎有待欠妥当。
/////仅自己查漏补缺用,如有问题,欢迎指出
2. 当使用手势,返回时要监听是否真正返回,然后添加相应的消息传递。
首先想到是通过手势delegate的监听来完成。
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer。发现手势每次都会触发此方法。无法判断是否成功返回。
然后想到了用navigationController的delegate来监听。果然能达到想要效果
#pragma mark - UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { id<UIViewControllerTransitionCoordinator> tc = navigationController.topViewController.transitionCoordinator; [tc notifyWhenInteractionEndsUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> context) { NSLog(@" Is cancelled: %i", [context isCancelled]); if (![context isCancelled]) { ///// do something (update UI ) } }]; }
但,我在更改NavigationControllerDelegate时想要保存之前的<UINavigationControllerDelegate>,以便返回后再将代理更改回去。
navigationDelegate = self.navigationController.delegate; self.navigationController.delegate = self;
if (![context isCancelled]) { self.navigationController.delegate = navigationDelegate; }但并不是想像中那么美好,无法再给代理赋给之前的对象,实际上是能获取到navigationDelegate的对象,但为什么之前的对象不能再响应UINavigationControllerDelegate的代理了,我也没太搞清,希望有知道者能告诉我…
我是把代理更改放到
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; self.navigationController.delegate = self; }
里解决的,但似乎有待欠妥当。
/////仅自己查漏补缺用,如有问题,欢迎指出
相关文章推荐
- UINavigationController
- UINavigationControll采用pushViewController后如何去掉左边的返回按钮
- UINavgationBar之UIBarButtonItem
- Foundation 心得、笔记
- UINavigationController总结
- 给UITabbarController 和 UINavigationController添加过场动画
- iOS开发中遇到的一些问题以及解决办法总结
- UI_NavigationController
- swift下如何配置引导页后跳转rootViewController
- UINavigationController使用简介
- 更改navigationController的navigationBar的返回按钮的图片
- OC笔记 - 控制器管理、UINavigationController、segue、控制器的数据传递(2015.3.16)
- NavigationController单个界面横屏,其他全竖屏
- UINavigationController以及UITabBarController背景图片和文字的设置
- 控制器跳转
- IOS UINavigationController 中添加UITabBarItem
- 重写导航控制器,利用重写pop和push方法来隐藏底层的tabbar和其他一些事件
- 解决UINavigationController自定义返回键后没有侧滑返回效果的问题
- iOS--导航栏属性设置的介绍
- iOS开发系列--视图切换