LeftBarButtonItem在IOS7以后的返回方法,和scrollToTop的问题

先说LeftBarButtonItem

项目的NAV结构略复杂,首页是一个nav,然后push到一个tabbar是四个nav
在tabbar里加入系统返回手势,在tabbar那里左侧边缘右滑会有莫名其妙的bug出现。
解决方法如下:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    /**
     *  侧边滑动效果
     */
        NSArray *arr = self.navigationController.viewControllers;
        if (arr.count <= 1) {
            //不加返回
            self.navigationController.interactivePopGestureRecognizer.delegate = nil;
            self.navigationController.interactivePopGestureRecognizer.enabled = NO;
        }
        else
        {
            //加返回
            self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
            self.navigationController.interactivePopGestureRecognizer.enabled = YES;
        }
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    //ios7返回手势
    if (IOS7_OR_LATER) {
        //(左滑返回)代理置空,否则会闪退
        if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
            self.navigationController.interactivePopGestureRecognizer.delegate = nil;
        }
    }
//delegate
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    //开启滑动手势
    if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        navigationController.interactivePopGestureRecognizer.enabled = YES;
    }
}

这么搞就没bug了。。

然后是关于scrollToTop的

我在一个页面的tableView,scrollToTop不生效,然后我一个个看这个VC的subView,结果发现,一个textView的默认属性,是scrollToTop = YES;我和我的小伙伴都惊呆了。。。。

碎碎念一下,项目的下个版本,应该就不支持IOS6了,我决定撒花庆祝下。

简书已经弃用,欢迎移步我的小专栏:
https://xiaozhuanlan.com/dahuihuiiOS

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,312评论 4 61
  • 沟通成本太高,大家都在推脱,工作上就是如此吧,哎 晚上和湘绚喝粥,好久没见,每个地方都大同小异,自己加油才是正道。
    聂一一阅读 109评论 0 0
  • 清醒小刻没错 ,我又开始瞎闹了
    实在想不出昵称丶阅读 101评论 0 0
  • 心灵自由写作第十四篇 学校教学楼的后面,有个山坡,山坡上长满了各种各样的树。有几棵树长得特别高,都高过了教学楼。从...
    正念此心阅读 402评论 1 4