简体   繁体   English

这是 iOS 14 UISplitViewController 错误吗?

[英]Is this an iOS 14 UISplitViewController bug?

In my app, I want a three-column UISplitViewController .在我的应用程序中,我想要一个三列的UISplitViewController I create it like this:我这样创建它:

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

This ViewController that I'm presenting is a really simple viewController.我展示的这个 ViewController 是一个非常简单的 viewController。 It doesn't do anything except, present a centered red square.除了显示居中的红色正方形外,它什么都不做。

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
    }
}

Now, when I run this code, I get the following result.现在,当我运行这段代码时,我得到了以下结果。

在此处输入图像描述

As you can see, 2 of the 3 squares are off-center.如您所见,3 个方块中有 2 个偏离中心。 Anyone know, what I'm doing wrong here?任何人都知道,我在这里做错了什么? Or is this a known bug?或者这是一个已知的错误?

  1. You should use "Safe Area" instead of "self.view" when setting to center.设置居中时,您应该使用“安全区域”而不是“self.view”。
  2. The detail view here has a push-away effect.此处的详细视图具有推开效果。 You just need to click on it and the primary view controller will hide, like below.您只需单击它,主视图 controller 就会隐藏,如下所示。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 嵌入在 UITabBarController 中的 UISplitViewController 在 iOS 14 中表现异常 - UISplitViewController embedded in UITabBarController behaves strange in iOS 14 UISplitViewController在iOS 9中是否存在保留周期错误? - Does UISplitViewController have a retain cycle bug in iOS 9? iOS 14 UISplitViewController 在 iPad 上移除横向的“隐藏/显示”按钮? - iOS 14 UISplitViewController remove "hide/show" button in landscape on iPad? iOS 14 中的 UISplitViewController 在横向模式下按预期工作,但在纵向模式下不起作用 - UISplitViewController in iOS 14 works as intended in landscape mode, but not in portrait 进入多任务时更改 UISplitViewController displayMode 属性? (iOS 14) - Change UISplitViewController displayMode property when entering multitasking? (iOS 14) iOS 14 和模拟器 UILabel 扩展填充错误 - iOS 14 and Simulator UILabel extension padding bug 带有调试器的 iOS14 自动旋转错误 - iOS14 Autorotation bug with debugger UISplitViewController与tableView作为detailView错误 - UISplitViewController with tableView as detailView bug Swift UISplitViewController - 无法在详细视图之前呈现主视图(iOS 14,Xcode 12.4) - Swift UISplitViewController - unable to present master view before detail view (iOS 14, Xcode 12.4) 继承UISplitViewController时的奇怪错误 - Strange bug when subclassing UISplitViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM