V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
yfmir
V2EX  ›  iDev

大伙都是怎样处理 navigation 的 interactivePopGestureRecognizer 的?

  •  
  •   yfmir · 2015-07-20 10:10:01 +08:00 · 3555 次点击
    这是一个创建于 3400 天前的主题,其中的信息可能已经有所发展或是发生改变。
    事情起因是因为自定义了leftItem之后pop手势失效,然后重新对interactivePopGestureRecognizer的delegate进行重新赋值。

    问题是当在topView的时候触发pop手势(沿着屏幕左边缘右滑),然后再进行push操作(比如说点击tableView某一行进入下一页),会出现push动画失效的情况,即UI还是在当前页,home键后重新进入恢复正常。
    4 条回复    2015-07-20 11:53:36 +08:00
    kobe1941
        1
    kobe1941  
       2015-07-20 10:47:04 +08:00
    在BaseViewController里开启或禁用

    -(void)viewDidAppear:(BOOL)animated
    {
    [super viewDidAppear:animated];
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
    if ([self.navigationController.viewControllers count] > 1) {
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    }else{

    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    self.navigationController.interactivePopGestureRecognizer.delegate = nil;
    }
    }
    }
    Zrocky
        2
    Zrocky  
       2015-07-20 11:51:02 +08:00
    我是在自定义的NavigationController中写的
    - (void)viewDidLoad {
    [super viewDidLoad];

    self.delegate = self;

    self.popGestureDelegate = self.interactivePopGestureRecognizer.delegate;
    }


    #pragma mark - UINavigationControllerDelegate

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

    if (viewController == self.viewControllers[0]) {
    self.interactivePopGestureRecognizer.delegate = self.popGestureDelegate;
    }else {
    self.interactivePopGestureRecognizer.delegate = nil;
    }
    }
    yfmir
        3
    yfmir  
    OP
       2015-07-20 11:51:04 +08:00
    @kobe1941 感谢,经测试可行
    yfmir
        4
    yfmir  
    OP
       2015-07-20 11:53:36 +08:00
    @Zrocky 我之前也考虑过这种方案,但是对我这个项目不太可行
    之前把delegate抽成单例了,以为是我自己少实现了什么方法,结果钻牛角尖了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2823 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 02:17 · PVG 10:17 · LAX 18:17 · JFK 21:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.