美文网首页
UISearchController设置导航栏隐藏时偏移-64解

UISearchController设置导航栏隐藏时偏移-64解

作者: 不会算卦的杨大仙 | 来源:发表于2016-08-27 14:33 被阅读2772次

初始化UISearchController的时候添加以下代码

self.definesPresentationContext = YES;

这行代码是声明,哪个viewcontroller显示UISearchController,苹果开发中心的demo中的对这行代码,注释如下
// know where you want UISearchController to be displayed
a、如果不添加上面这行代码,在设置hidesNavigationBarDuringPresentation这个属性为YES的时候,搜索框进入编辑模式会导致,searchbar不可见,偏移-64;
在设置为NO的时候,进入编辑模式输入内容会导致高度为64的白条,猜测是导航栏没有渲染出来
b、如果添加了上面这行代码,在设置hidesNavigationBarDuringPresentation这个属性为YES的时候,输入框进入编辑模式正常显示和使用;在设置为NO的时候,搜索框进入编辑模式导致向下偏移64

相关文章

网友评论

      本文标题:UISearchController设置导航栏隐藏时偏移-64解

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