iOS之侧滑返回无需第三方,只需在自己的BaseNavController添加大概20行代码即可
来源:互联网 发布:淘宝大学出来有学历吗 编辑:程序博客网 时间:2024/05/18 08:53
效果图
21.gif
实现步骤:
1、viewDidLoad需要做的事情
1
2
3
4
5
6
7
8
self.delegate = self;
__weak
typeof
(self) weakSelf = self;
if
([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.interactivePopGestureRecognizer.delegate = weakSelf;
}
2、实现UIGestureRecognizerDelegate代理中的方法
1
2
3
4
5
6
7
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
if
(self.navigationController.viewControllers.count ==
1
) {
return
NO;
}
else
{
return
YES;
}
}
3、实现UINavigationControllerDelegate代理中的方法
1.实现didShowViewController方法
1
2
3
4
5
6
7
8
9
10
11
- (
void
)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
if
([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
navigationController.interactivePopGestureRecognizer.enabled = YES;
}
//使navigationcontroller中第一个控制器不响应右滑pop手势
if
(navigationController.viewControllers.count ==
1
) {
navigationController.interactivePopGestureRecognizer.enabled = NO;
navigationController.interactivePopGestureRecognizer.delegate = nil;
}
}
2.此方法中拦截所有push 进来的控制器
1
2
3
4
5
6
-(
void
)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
if
([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.interactivePopGestureRecognizer.enabled = NO;
}
[
super
pushViewController:viewController animated:animated];
}
阅读全文
0 0
- iOS之侧滑返回无需第三方,只需在自己的BaseNavController添加大概20行代码即可
- 自己开发的一款基于PagedDataSource的datalist repeater控件,只需要在源程序中添加三行代码,即可实现通用分页
- 无需第三方软件即可查询好友IP地址 (1)
- ffmpeg 添加自己的第三方库
- IOS 项目开发 必备的第三方类及需自己开发的第三方
- ios如何添加第三方的字体库
- 从第三方app返回自己的app
- android无需第三方sdk的分享
- Android开发如何在自己的项目中引用第三方代码
- iOS处理分享时,在三方应用中无法返回自己应用的问题
- ios 添加第三方字体
- ios添加第三方字体
- iOS 添加第三方字体库
- iOS之KxMenu第三方的使用
- 用FME集成第三方工具(无需代码)
- iOS集成第三方登录(SSO授权登录<无需密码>
- IOS第三方代码收集
- ios调用第三方程序打开文件,以及第三方调用自己的APP打开文件
- “强化学习之父”萨顿:预测学习马上要火,AI将帮我们理解人类意识
- 2017 人工智能+内容生产研究报告【附下载】
- 计算机视觉大规模爆发,6大细分领域将撑起725亿元市场
- js--打卡--12.13 DOM全选练习
- WPF--DataGrid的使用
- iOS之侧滑返回无需第三方,只需在自己的BaseNavController添加大概20行代码即可
- Android Studio 解决格式化快捷键和QQ 锁键盘快捷键冲突
- 23种设计模式(7)-代理模式
- Linux ELF文件学习(1)
- idea:设置SVN忽略文件和文件夹
- 《数字技术》连载19: 第2章 数字器件 第14节 非电-电 转换用的数字器件
- 以太坊资料
- MySQL 数据库基础知识 1
- 图片缓存-glide