ios - 布局问题 Xcode - 搜索栏自动移动

标签 ios swift xcode uisearchbar

我遇到了这个问题,不知道怎么解决

在 mainstoryboard 中,我为 Top Bar 设置了 auto top layout 为 20 首先,我的搜索栏(顶部栏)的 y 位置是 84,但看起来像这样,我一直想要我的应用程序

enter image description here

但是,当我选择搜索栏时,我使用 func searchBarTextDidBeginEditing(searchBar: UISearchBar) 显示另一个栏,但即使另一个没有显示,我的搜索栏(顶部栏)也会移动下来,我看起来一点都不好,但现在是 y 位置:20 ?? 这是它的样子

enter image description here

那么,有人可以帮我解决这个问题吗??非常感谢

最佳答案

在 viewDidLoad 方法中试试这个

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
{ 
self.automaticallyAdjustsScrollViewInsets=YES;
self.edgesForExtendedLayout = UIRectEdgeNone;
self.navigationController.view.backgroundColor = [UIColor whiteColor];
self.navigationController.navigationBar.translucent = YES;
}

关于ios - 布局问题 Xcode - 搜索栏自动移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41208316/

相关文章:

ios - 我的测试目标中没有这样的模块 'XXX'

xcode - 没有名为 'UIApplicationDelegate' 的类型或协议(protocol)

xcode - 如何在 Xcode, swift 2 中将一个文本字段中的标记文本显示为其他文本字段中的标记文本

ios - 我如何显示与附加到 UITabBarControLler 的 ViewController 不同的 ViewController

带有字体手提箱的 iPhone 自定义字体

ios - 无法验证 : Could not find a CFBundlePackageType

Swift 运行时异常 : unrecognized selector

ios - 如何在 Swift3 iOS 中的特定持续时间内在 AVPlayer 中播放视频

iOS 推送通知 - 角标(Badge)不会显示

python - 如何在插件的 Objective-C OS X 应用程序中嵌入 python?