1

デバイスの向きが変わってもプレゼンテーション コントローラの高さを維持する方法。以下はコードです:

    func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController!, sourceViewController source: UIViewController) -> UIPresentationController? {
        return MyPresentationController(presentedViewController: presented, presentingViewController: presenting)
    }

    class MyPresentationController : UIPresentationController {
        override func frameOfPresentedViewInContainerView() -> CGRect {

        let controllerHeight:CGFloat = 200.0
        let width = UIScreen.main.bounds.width
        let height = UIScreen.main.bounds.height

        return CGRect(x: 0.0, y: height - controllerHeight, width: width, height: controllerHeight)
        }
    }

    let pvc = MyPresentationController()
    pvc.modalPresentationStyle = UIModalPresentationStyle.Custom
    pvc.transitioningDelegate = self

ここにコードサンプルがあります

4

1 に答える 1