如何为UINavigationController启用全屏平移

时间:2016-02-16 08:32:30

标签: ios gesture uipangesturerecognizer

从iOS7苹果提供了一种平移UINavigationController的方法,但它只能通过滑动屏幕边缘来完成。如何启用全屏平移手势?

1 个答案:

答案 0 :(得分:3)

我真的花了很多时间试图解决这个问题,最后我找到了方法。我只是问一个问题并自己回答,在这里分享解决方案。

请参阅我的博客以获取更多详细信息enter link description here

演示代码:

#import "TestNavigationController.h"

@interface _UINavigationInteractiveTransition

@end

@interface UINavigationController(Custom)
@property (strong, nonatomic) _UINavigationInteractiveTransition * _cachedInteractionController;

@end

@implementation TestNavigationController
{
    UIPanGestureRecognizer *_p;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"%@", self.interactivePopGestureRecognizer
          );
    _p = [[UIPanGestureRecognizer alloc]initWithTarget:self._cachedInteractionController action:@selector(handleNavigationTransition:)];
    NSLog(@"%@", self._cachedInteractionController);
    [self.view addGestureRecognizer:_p];
   } 
@end

编辑注意: 这暴露了私有API。