美文网首页
iOS11碰到的问题集合

iOS11碰到的问题集合

作者: l富文本l | 来源:发表于2017-12-14 18:23 被阅读0次

    1、tableView或者collectionView向下偏移

    原因是iOS 11中Controller的automaticallyAdjustsScrollViewInsets属性被废弃了,所以当tableView超出安全区域时系统自动调整了SafeAreaInsets值,进而影响adjustedContentInset值,在iOS 11中决定tableView的内容与边缘距离的是adjustedContentInset属性,而不是contentInset。因为系统对adjustedContentInset值进行了调整,所以导致tableView的内容到边缘的距离发生了变化,导致tableView下移了20pt(statusbar高度)或64pt(navigationbar高度)。

    如果你的APP中使用的是自定义的navigationbar,隐藏掉系统的navigationbar,并且tableView的frame为(0,0,SCREEN_WIDTH, SCREEN_HEIGHT)开始,那么系统会自动调整SafeAreaInsets值为(20,0,0,0),如果使用了系统的navigationbar,那么SafeAreaInsets值为(64,0,0,0),如果也使用了系统的tabbar,那么SafeAreaInsets值为(64,0,49,0)。

    解决方法:

    #ifdef __IPHONE_11_0
            if ([_collectionView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
                _collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
            }
    #endif
    

    2、导航栏translucen = NO的时候x = 0,y = 0的点在左上角而不是导航栏底下

    controller中加这行代码

    self.edgesForExtendedLayout = UIRectEdgeNone;
    

    相关文章

      网友评论

          本文标题:iOS11碰到的问题集合

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