XIB
。我希望这是正方形。我弄清楚了如何使其在模拟器中进行正方形,但是它不是实际iPad上的平方。为了使其保持平方,我将此代码包括在
viewDidLoad
:中:
super.viewDidLoad()
let screenSize = min(UIScreen.main.bounds.width, UIScreen.main.bounds.height)
preferredContentSize = CGSize(width: screenSize - 50, height: screenSize - 50)
这就是它在模拟器上显示的方式。
这就是它在物理iPad上显示的方式。
我注意,这是一个仅肖像的应用程序。使用变换旋转到适当的每个玩家的方向,大概坐在桌子旁,iPad躺在平坦的桌子上。转换逻辑没有问题。那么,为什么
preferredContentSize
在模拟器上工作,而不能在物理设备上使用呢?也许是相关的,模拟器位于iPados 18上,该设备在iPados上17.
this是如何提出的:
XIB
这个似乎解决了我的问题,我将其更改为以下方式:
private func showCrosswordViewController() {
let crosswordViewController = CrosswordViewController(nibName: "CrosswordViewController", bundle: nil)
crosswordViewController.delegate = self
crosswordViewController.view.transform = .identity.rotated(by: activePlayerAngle)
if let activePlayerHomeView = activePlayerHomeView() {
crosswordViewController.cardViews.removeAll(keepingCapacity: true)
for sv in activePlayerHomeView.subviews {
if let cardView = sv as? CardView {
cardView.cell = nil
crosswordViewController.cardViews.append(cardView)
}
}
}
let sideCount = 12 - (playerPositions.count - 2)
crosswordViewController.cellsPerRow = sideCount
present(crosswordViewController, animated: true)
}