zoukankan      html  css  js  c++  java
  • Xamarin.Forms 强迫横竖屏

    只要在MainActivity中设置

    this.RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait;//竖屏,禁止横屏

    this.RequestedOrientation = Android.Content.PM.ScreenOrientation.Nosensor;//横屏,禁止竖屏
    ---------------------

    Android:

     1  public void ForceLandscape()
     2         {
     3             GetActivity().RequestedOrientation = ScreenOrientation.Landscape;
     4         }
     5 
     6 
     7         public void ForcePortrait()
     8         {
     9             GetActivity().RequestedOrientation = ScreenOrientation.Portrait;
    10         }
    11 
    12  
    13 
    14         public Activity GetActivity()
    15         {
    16             var activity = (Activity)Forms.Context;
    17             return activity;
    18         }

    IOS:

           

     1  public void ForceLandscape()
     2         {
     3             UIDevice.CurrentDevice.SetValueForKey(new NSNumber((int)UIInterfaceOrientation.LandscapeLeft), new NSString("orientation"));
     4         }
     5 
     6 
     7         public void ForcePortrait()
     8         {
     9             UIDevice.CurrentDevice.SetValueForKey(new NSNumber((int)UIInterfaceOrientation.Portrait), new NSString("orientation"));
    10         }

    原文:https://blog.csdn.net/u012069227/article/details/51437345

  • 相关阅读:
    Node.js中流程控制
    设计模式六大原则(转)
    Python中装饰器(转)
    cocos2d-js反射
    With as
    Python中sort与sorted函数
    cocos+kbe问题记录
    Python字符串
    vue判断Object对象是否包含每个键
    vue跳转其他页面并传参
  • 原文地址:https://www.cnblogs.com/Xamarin-Oz/p/11069199.html
Copyright © 2011-2022 走看看