Custom size for Modal View loaded with Form Sheet presentation

前端 未结 10 747
予麋鹿
予麋鹿 2021-02-01 12:44

I\'m trying to load a UIViewController in iPad with Form Sheet presentation. The problem is the size of this new view, i put the size values in the IBuilder but the modal view t

10条回答
  •  时光说笑
    2021-02-01 13:14

    Setting preferredContentSize didn't work for me on iOS 11 for example when presenting EKEventEditViewController.

    It works only if I override getter of preferredContentSize. Something like this:

    private class CLEventEditViewController: EKEventEditViewController {
        override var preferredContentSize: CGSize {
            get {
                if let fullSize = self.presentingViewController?.view.bounds.size {
                    return CGSize(width: fullSize.width * 0.5,
                                  height: fullSize.height * 0.75)
                }
                return super.preferredContentSize
            }
            set {
                super.preferredContentSize = newValue
            }
        }
    }
    

提交回复
热议问题