2017-10-30 5 views
1

は、私は
何も働いていないXamarinのiOS防止回転

public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation) 
    { 
     return false; 
    } 


    public override bool ShouldAutorotate() 
    { 
     return false; 
    } 


    public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation() 
    { 
     return UIInterfaceOrientation.Portrait; 
    } 


    public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations() 
    { 
     return UIInterfaceOrientationMask.Portrait; 
    } 


below-しようとした特定のビューコントローラ
上の画面の回転を阻止する必要があります。

ありがとうございました!

答えて

4

この問題をこの説明で解決できます。あなたが)例

public bool disableAllOrientation = false; 

2のためのブール値を追加しますAppDelegate

public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations(UIApplication application, UIWindow forWindow) 
     { 
      if (disableAllOrientation == true) 
      { 
       return UIInterfaceOrientationMask.Portrait; 
      } 
      return UIInterfaceOrientationMask.All; 
     } 

3)あなたが方向を変更するビューのコントローラのコールであなたのUIInterfaceOrientationnMaskを変更AppDelegateで

1)

appDelegate.disableAllOrientation = true; 

4)また、ビューが閉じるか変更する必要がある場合ブール値 を再度falseに設定し、必要に応じて画面を元の向きにします。

appDelegate.disableAllOrientation = false; 

私はこの問題があなたの問題を解決することを願っています。

+0

ありがとうMarcos!今働いている! –

+1

あなたの歓迎Nikhil、この作品、逆の場合も。ポートレートアプリケーションがあり、1つのビューに対してすべての方向付けを有効にする場合。よろしく! –

+1

はい。実装を理解しました。 AppDelegateを使って制御できます。 乾杯 –

関連する問題