iOS 8: Presenting a modal view controller in portrait causes resize of the navigation bar of the underlying landscape navigation controller

后端 未结 1 1856
無奈伤痛
無奈伤痛 2021-02-06 04:28

On iOS 8 I have a strange behavior regarding the navigation bar and orientation changes.

I have a navigation controller which reports a supported interface orientation <

相关标签:
1条回答
  • 2021-02-06 04:55

    For lack of a better option I've done a bit of a hack for this. Basically before I show the modal view I take a screen shot and lay it on top of the presenting view controller.

    Obviously I have to remove this screen shot when the view re-appears

      func showScreenShot () {
        let image = screenShot()
        self.screenShotImageView = UIImageView(image: image)
        self.view.addSubview(self.screenShotImageView!)
      }
    
    func screenShot () -> UIImage {
        UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, true, UIScreen.mainScreen().scale)
        self.view.layer.renderInContext(UIGraphicsGetCurrentContext())
        let image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        return image
    }
    
    func removeScreenShot () {
      if let screenImageView = self.screenShotImageView {
       screenImageView.removeFromSuperview()
       self.screenShotImageView = nil
      }
    }
    
    0 讨论(0)
提交回复
热议问题