2017-01-14 5 views
0

私はアンケートiMessageアプリケーション(私が知っている)と、プレゼンテーションモード間での移動に問題があります。下の一連のスクリーンショットは、アプリが起動すると、コンパクトモードですべてが正常であることを示しています。拡張され、すべてが正しいが、その後、私は、コンテンツを圧縮するために戻ったときに大きなメッセージナビゲーションバーと同じ高さにどのように見えるかによってシフトダウンされている場合は、私が試したTopAnchor of viewController iMessage内での変更プレゼンテーションモード間の拡張

enter image description here

(86私は信じています)コンパクトビューに戻ったときに上部の制約を-86に設定すると、これは何もしないか、またはどこにあるかに戻してから86を引いて、あまりにも高くなってしまいます。私は、この問題はどこから来ているので、わからないアプリからアイスクリームのサンプルプロジェクトにこのプロジェクトをベースとしました(おそらく自動レイアウトが、すべては、レイアウトガイドに固定されている)

はここでビューコントローラ追加するコードです:

func loadTheViewController(controller: UIViewController) { 
    // Remove any existing child controllers. 
    for child in childViewControllers { 
     child.willMove(toParentViewController: nil) 
     child.view.removeFromSuperview() 
     child.removeFromParentViewController() 
    } 

    // Embed the new controller. 
    addChildViewController(controller) 

    controller.view.frame = view.bounds 
    controller.view.translatesAutoresizingMaskIntoConstraints = true 
    view.addSubview(controller.view) 

    controller.view.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true 
    controller.view.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true 
    controller.view.topAnchor.constraint(equalTo: view.topAnchor).isActive = true 
    controller.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true 

    controller.didMove(toParentViewController: self) 
} 

私は永遠に感じることのためにこれについて作業していますので、どんな提案も歓迎します。

答えて

1

ビューに制約を設定していますが、translatesAutoresizingMaskIntoConstraintsをtrueに設定しています。自動サイズ変更マスクの制約が追加する制約と競合する可能性があり、予期しない結果が発生します。あなたのアカウントに上部のナビゲーションバーがかかりますtopLayoutGuideにピンなければならない、むしろview.topAnchorにピン留めよりも

controller.view.translatesAutoresizingMaskIntoConstraints = false 

:あなたがに変わります。

controller.view.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor).isActive = true 

同様

controller.view.bottomAnchor.constraint(equalTo: bottomLayoutGuide.topAnchor).isActive = true 
+0

おかげで、それはそれをソートしています。私はAppleのIceCreamサンプルアプリケーションをチェックして、 'translatesAutoresizingMaskIntoConstraints'を変更したように見えますが、なんらかの理由でlayoutguideではなくtopAnchorに固定されています。 – SimonBarker

関連する問題