[英]UISplitViewController embedded in UITabBarController behaves strange in iOS 14
[英]Is this an iOS 14 UISplitViewController bug?
在我的應用程序中,我想要一個三列的UISplitViewController
。 我這樣創建它:
let svc = UISplitViewController(style: .tripleColumn)
svc.preferredDisplayMode = .twoOverSecondary
svc.setViewController(TestViewController(), for: .primary)
svc.setViewController(TestViewController(), for: .supplementary)
svc.setViewController(TestViewController(), for: .secondary)
svc.primaryBackgroundStyle = .sidebar
我展示的這個 ViewController 是一個非常簡單的 viewController。 除了顯示居中的紅色正方形外,它什么都不做。
class TestViewController: UIViewController {
private var redView = UIView()
override func viewDidLoad() {
super.viewDidLoad()
redView.backgroundColor = .red
redView.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(redView)
redView.widthAnchor.constraint(equalToConstant: 30).isActive = true
redView.heightAnchor.constraint(equalToConstant: 30).isActive = true
redView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
redView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true
}
}
現在,當我運行這段代碼時,我得到了以下結果。
如您所見,3 個方塊中有 2 個偏離中心。 任何人都知道,我在這里做錯了什么? 或者這是一個已知的錯誤?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.