wcoder / Xamarin.Plugin.DeviceOrientation

Cross-platform plugin to work with screen orientation of mobile device.
MIT License
61 stars 19 forks source link

Orientation lock does not work on iOS #16

Open tompi opened 6 years ago

tompi commented 6 years ago

Tried to use the nuget package without success, so I cloned the repo and started the sample app on an ipad with ios 11.3.1.

Screen rotates even if label says locked...

This is the case for both the samples-solution and the TestNugetDeviceOrientationPlugin

DKANomad commented 5 years ago

If you haven't fixed this yet, I was able to get it working by adding the code:

[Export("application:supportedInterfaceOrientationsForWindow:")]    
public UIInterfaceOrientationMask GetSupportedInterfaceOrientations(UIApplication application, IntPtr forWindow)
{
     return Plugin.DeviceOrientation.DeviceOrientationImplementation.SupportedInterfaceOrientations;
}

to the AppDelegate

pidgy commented 5 years ago

If you haven't fixed this yet, I was able to get it working by adding the code:

[Export("application:supportedInterfaceOrientationsForWindow:")]    
public UIInterfaceOrientationMask GetSupportedInterfaceOrientations(UIApplication application, IntPtr forWindow)
{
     return Plugin.DeviceOrientation.DeviceOrientationImplementation.SupportedInterfaceOrientations;
}

to the AppDelegate

Worked for me

NebulaSleuth commented 4 years ago

This doesn't work for me in a Xamarin.Forms iOS app on my iPad. Android works fine. The method GetSupportedInterfaceOrientations never gets called. I pulled the repo and tried the sample app and it didn't work either (its not Xamarin.Forms). Is there something incompatible with certain iOS or Xamarin versions? Xamarin.Forms does not expose the ViewController so Not sure it that is related.

udayaugustin commented 4 years ago

I faced the same issue on the iPad. In iPad we need to disable the split-screen feature, to lock the orientation. Set RequireFullScreen to in the Xamarin.iOS info.plist file.