【问题标题】:View not filling parent correctly查看未正确填写父项
【发布时间】:2016-01-22 10:55:21
【问题描述】:

我已将背景设置为紫色的视图控制器中有一个 UIView。

就这么简单

但是它没有正确排列......

从启用了“显示剪辑的内容”的调试视图层次结构来看,它似乎将自身对齐到左侧...这似乎是它与右侧边缘不匹配的原因...

这实际上只是一个简单的视图。我没有做任何花哨的事情,没有任何限制等。这让我发疯了。

编辑:

好的.. 事实证明 iPhone 6 plus 上一切正常,问题出在其他 iPhone 设备尺寸上...See my other questions where I thought that the 6+ was incorrect... 但它实际上是唯一一个做正确的事情!

【问题讨论】:

    标签: ios storyboard autolayout interface-builder


    【解决方案1】:

    这是我切换 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)
    })
    

    它解决了我的问题...我还不够先进,还不知道是什么原因造成的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多