c# - Can't lock one view controller in Portrait , xamarin IOS -


i trying make 1 view controller locked in portrait while allowing other views orientation. have tried put in homeviewcontroller ( 1 want keep in portrait).

public override uiinterfaceorientationmask getsupportedinterfaceorientations()     {         return uiinterfaceorientationmask.portrait;     }     public override uiinterfaceorientation preferredinterfaceorientationforpresentation()     {         return uiinterfaceorientation.portrait;     }     public override bool shouldautorotate()     {         return false;     } 

i trying in xamarin in c#. have suggestions?

i derive controllers 1 base. need other purposes use lock portrait orientation

public class baseview : uiviewcontroller {      static list<type> supportinglandscapescreentypes = new list<type>()     {         typeof(temperatureshistoryview),          typeof(loadswitchconsumptionview),          typeof(homeconsumptiongraphview)      };      public override uiinterfaceorientationmask getsupportedinterfaceorientations()     {         foreach (var screentype in supportinglandscapescreentypes)         {             if (gettype() == screentype)                 return uiinterfaceorientationmask.portrait | uiinterfaceorientationmask.landscapeleft | uiinterfaceorientationmask.landscaperight;         }         return uiinterfaceorientationmask.portrait;     }      public override uiinterfaceorientation preferredinterfaceorientationforpresentation()     {         return uiinterfaceorientation.portrait;     }  }  public class myenergateappnavigationcontroller:uinavigationcontroller {     public myenergateappnavigationcontroller(uiviewcontroller rootcontroller)         :base (rootcontroller)     {     }      public override bool shouldautorotate()     {         return true;     }      //[obsolete ("deprecated in ios6. replace both getsupportedinterfaceorientations , preferredinterfaceorientationforpresentation")]     //public override bool shouldautorotatetointerfaceorientation(uiinterfaceorientation tointerfaceorientation)     //{     //    return topviewcontroller.shouldautorotatetointerfaceorientation(tointerfaceorientation);     //}      public override uiinterfaceorientationmask getsupportedinterfaceorientations()     {         return topviewcontroller.getsupportedinterfaceorientations();     }      public override uiinterfaceorientation preferredinterfaceorientationforpresentation()     {         return topviewcontroller.preferredinterfaceorientationforpresentation();     } } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -