进行轮换时,我会看到一个不合适的视图/场景。 viewWillTransition方法如下:
public class PopupWithArrow extends PopupDialog
{
public PopupWithArrow(Shell shell)
{
super(shell, SWT.NO_TRIM | SWT.MODELESS | SWT.NO_FOCUS,
false, false, false, false, false, null, null);
}
}
有人可以让我知道我做错了吗?
谢谢
答案 0 :(得分:2)
试试这个,
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let skView = self.view as! SKView
if let sceneNode = skView.scene as! GameScene? {
sceneNode.size = self.view.frame.size
sceneNode.position = CGPoint(x: self.view.frame.midX, y: self.view.frame.midY)
}
}
答案 1 :(得分:0)
Thx @AshokPolu!
我之所以这样,是因为尺寸会随着设备旋转动画而变化。
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
coordinator.animateAlongsideTransition(in: self.view, animation: { (_) in
if let skView = self.view as? SKView, let scene = skView.scene as? GameScene {
scene.size = self.view.frame.size
scene.position = CGPoint(x: self.view.frame.midX, y: self.view.frame.midY)
}
}, completion: nil)
}