美文网首页
ios整体侧滑

ios整体侧滑

作者: 于国文奋斗的少年 | 来源:发表于2017-12-12 17:57 被阅读0次

ios侧滑的封装  来点儿实际的 直接撸代码 简单搞定

a,实现方法 viewdidload中

- (void)viewDidLoad {

[super viewDidLoad];

self.delegate = self;

__weak typeof(self) weakSelf = self;

if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

self.interactivePopGestureRecognizer.delegate = weakSelf;

}

}

b,实现UIGestureRecognizerDelegate中的方法

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{

if (self.navigationController.viewControllers.count == 1) {

return NO;

}else{

return YES;

}

}

c 实现UINavigationControllerDelegate 的方法

- (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;

}

}

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{

if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

self.navigationController.interactivePopGestureRecognizer.enabled = NO;

}

[self.navigationController pushViewController:viewController animated:animated];

}

这就完成了  奋斗吧骚年

相关文章

  • ios整体侧滑

    ios侧滑的封装 来点儿实际的 直接撸代码 简单搞定 a,实现方法 viewdidload中 - (void)vi...

  • 导航控制器切换效果

    自定义侧滑效果,侧滑返回时界面整体滑动。 相关文章: 【iOS】让我们一次性解决导航栏的所有问题 如何实现类似网易...

  • iOS 三种侧滑菜单效果对比详解

    侧滑菜单 ios分类:iOS界面布局 DDMenu(传统侧滑效果)下载地址:https://github.com/...

  • iOS侧滑

    由于项目中需要侧滑效果,找到一个差不多的demo,在前辈基础上自己加工一下,感觉还可以,用起来很方便 先上图 侧滑...

  • iOS 侧滑

    ViewDeck 左右侧滑控件 MSDynamicsDrawerViewController iOS7 动态弹...

  • iOS开源项目推荐|侧滑与右滑返回手势

    iOS开源项目推荐|侧滑与右滑返回手势

  • iOS之侧滑返回无需第三方,只需在自己的BaseNavContr

    iOS之侧滑返回无需第三方,只需在自己的BaseNavController添加大概20行代码即可 iOS之侧滑返回...

  • iM

    ios IM 架构设计 ios IM 网络层架构 ios 侧滑与右滑返回手势http://blog.csdn.n...

  • iOS侧滑返回

    相关原理 iOS侧滑返回,有三种方案可以实现(只考虑iOS7以后) 开启使用系统自带的侧滑返回self.navig...

  • iOS pop 侧滑返回处理

    方案一 : 开启使用系统自带的侧滑返回iOS7之后系统提供了侧滑手势(interactivePopGestureR...

网友评论

      本文标题:ios整体侧滑

      本文链接:https://www.haomeiwen.com/subject/lnvnixtx.html