查看未正确填写父项
View not filling parent correctly
我在视图控制器中有一个 UIView,我已将背景设置为紫色。
就这么简单
然而它没有正确排列...
从启用了 'show clipped content' 的调试视图层次结构来看,它似乎将自身对齐到左侧...这似乎就是它与右侧边缘不匹配的原因.. .
这真的只是一个简单的视图。我什么都不做,没有约束等等。这让我发疯。
编辑:
好的..事实证明在 iPhone 6 plus 上一切正常,问题出在其他 iPhone 设备尺寸上...... See my other questions where I thought that the 6+ was incorrect... 但它实际上是只有一个人在做正确的事!
这是我切换 UiView 控制器时某处的错误...
我改了
self.currentVC.willMoveToParentViewController(nil)
self.addChildViewController(newController)
self.transitionFromViewController(
self.currentVC!,
toViewController: newController,
duration: 0,
options: UIViewAnimationOptions.CurveEaseIn,
animations: nil,
completion: { finished in
self.currentVC.removeFromParentViewController()
newController.didMoveToParentViewController(self)
self.currentVC = newController
})
至
self.currentVC.willMoveToParentViewController(nil)
self.addChildViewController(newController)
self.view.addSubview(newController.view)
newController.view.alpha = 0
newController.view.layoutIfNeeded()
UIView.animateWithDuration(0.5, animations: {
newController.view.alpha = 1
self.currentVC.view.alpha = 0
},
completion: { finished in
self.currentVC.view.removeFromSuperview()
self.currentVC.removeFromParentViewController()
newController.didMoveToParentViewController(self)
})
它解决了我的问题...我还不够先进,不知道是什么原因造成的。
我在视图控制器中有一个 UIView,我已将背景设置为紫色。
就这么简单
然而它没有正确排列...
从启用了 'show clipped content' 的调试视图层次结构来看,它似乎将自身对齐到左侧...这似乎就是它与右侧边缘不匹配的原因.. .
这真的只是一个简单的视图。我什么都不做,没有约束等等。这让我发疯。
编辑:
好的..事实证明在 iPhone 6 plus 上一切正常,问题出在其他 iPhone 设备尺寸上...... See my other questions where I thought that the 6+ was incorrect... 但它实际上是只有一个人在做正确的事!
这是我切换 UiView 控制器时某处的错误...
我改了
self.currentVC.willMoveToParentViewController(nil)
self.addChildViewController(newController)
self.transitionFromViewController(
self.currentVC!,
toViewController: newController,
duration: 0,
options: UIViewAnimationOptions.CurveEaseIn,
animations: nil,
completion: { finished in
self.currentVC.removeFromParentViewController()
newController.didMoveToParentViewController(self)
self.currentVC = newController
})
至
self.currentVC.willMoveToParentViewController(nil)
self.addChildViewController(newController)
self.view.addSubview(newController.view)
newController.view.alpha = 0
newController.view.layoutIfNeeded()
UIView.animateWithDuration(0.5, animations: {
newController.view.alpha = 1
self.currentVC.view.alpha = 0
},
completion: { finished in
self.currentVC.view.removeFromSuperview()
self.currentVC.removeFromParentViewController()
newController.didMoveToParentViewController(self)
})
它解决了我的问题...我还不够先进,不知道是什么原因造成的。