iOS 3行代码搞定导航控制器全屏滑动返回效果
2015-09-14 11:36
721 查看
本文方法是从大神的方法中获得的启示。
在导航控制器里的最后一个视图控制器的viewDidLoad:中添加如下代码:
<span style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);">id target = self.navigationController.interactivePopGestureRecognizer.delegate;</span><br style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);" /><br style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);" /><span style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);">UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];//手势方法一定要写成</span><span style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);">handleNavigationTransition:,此方法为苹果内部已经实现的方法。</span><span style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);">
</span><br style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);" /><span style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);">[self.view addGestureRecognizer:pan];</span>
在导航控制器里的最后一个视图控制器的viewDidLoad:中添加如下代码:
<span style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);">id target = self.navigationController.interactivePopGestureRecognizer.delegate;</span><br style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);" /><br style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);" /><span style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);">UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];//手势方法一定要写成</span><span style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);">handleNavigationTransition:,此方法为苹果内部已经实现的方法。</span><span style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);">
</span><br style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);" /><span style="color: rgb(85, 85, 85); font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(245, 245, 245);">[self.view addGestureRecognizer:pan];</span>
相关文章推荐
- iOS开发——导航控制器
- swift 恢复 滑动返回 手势
- Android Activity向右滑动返回
- iOS开发UINavigationController导航控制器初始化,导航控制器栈的push和pop跳转理解
- 滑动返回库SwipeBackLayout解析
- iOS开发学习之#简单通讯录的制作#
- ios7 滑动返回
- iOS学习之UINavigationController详解与使用(二)页面切换和segmentedController
- iOS学习之UINavigationController详解与使用(三)ToolBar
- ios导航控制器UINavigationController,控制器a跳转(push)到b后,b跳转(push)到c,但c后退(pop)进入a
- ios滑动返回
- UINavigation
- Activity滑动返回操作,像iOS的UINavigationController、知乎的Android版那样
- 导航控制器和表视图(一)
- 导航控制器和表视图(二)
- UINavigationController与简单的页面传值
- iOS开发UINavigation系列四——导航控制器UINavigationController
- iOS7滑动返回
- 自定义UITabBarController
- Android滑动返回上一级界面