【发布时间】:2018-03-02 19:59:11
【问题描述】:
我的应用程序已经在应用商店中,昨天我将我的 Xcode 版本更新到了 9,并且除了 iPhone x 之外都可以正常工作。 UI 崩溃了。
1.这里我创建了两个 UIView(均为固定高度),分别命名为 Header 和 Tab bar,并且我隐藏了我的 NavigationBar 整个应用程序。
2.为UIViewController添加扩展,用于制作Header和Tab bar
func addHeaderTab(currentViewController:UIViewController,content:String, isMenu:Bool){
let noView = TopHeaderView()
noView.tag = 12345
noView.isMenu = isMenu
noView.translatesAutoresizingMaskIntoConstraints = false
currentViewController.view .addSubview(noView)
if isMenu{
noView.menuBtn .setImage(UIImage(named: "Small"), for: .normal)
noView.logoImg.isHidden = false
}else{
noView.menuBtn .setImage(UIImage(named: "arrow_small"), for: .normal)
noView.logoImg.isHidden = true
}
noView.titleLbl.text = content
noView.delegate = (currentViewController as! menuOpen)
NSLayoutConstraint(item: noView, attribute: .leading, relatedBy: .equal, toItem: currentViewController.view, attribute: .leading, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: noView, attribute: .trailing, relatedBy: .equal, toItem: currentViewController.view, attribute: .trailing, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: noView, attribute: .top, relatedBy: .equal, toItem: currentViewController.view, attribute: .top, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: noView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1.0, constant: 64).isActive = true
}
并在每个 Viewcontroller 中调用它,如下所示:
self.addHeaderTab(currentViewController: self, content:"நிகழ்ச்சி நிரல்" , isMenu: true)
就像那个标签栏我也做过,但所有设备都可以正常工作,预计 iPhone x。
查看我的屏幕截图:
我研究过https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/
但不清楚他们的文件。
我们将不胜感激,在此先感谢。
【问题讨论】:
标签: ios autolayout swift4 xcode9 iphone-x