您的位置:首页 > 移动开发 > IOS开发

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息