Hello,
I have implemented single page rotation to landscape in android using OnWindowVisibilityChanged
method in renderer for specific page.
But I couldn't figure it out for ios.
My code for iOS renderer is below.
`[assembly: ExportRenderer(typeof(Page3), typeof(CustomContentPageRenderer))]
namespace PhotoPages.iOS
{
public class CustomContentPageRenderer : PageRenderer
{
// App.IsPortrait is public static variable declared in App.cs and set to false in Page3 Constructor
// This method returns landscape mode but somehow page is not rotated.
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
{
return App.IsPortrait ? UIInterfaceOrientationMask.Portrait : UIInterfaceOrientationMask.LandscapeLeft;
}
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
App.IsPortrait = true;
}
//public override bool ShouldAutorotate()
//{
// return true;
//}
//public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation()
//{
// return UIInterfaceOrientation.LandscapeRight;
//}
//protected override void OnElementChanged(VisualElementChangedEventArgs e)
//{
// base.OnElementChanged(e);
// this.PreferredInterfaceOrienttionForPresentation();
// if(App.IsPortrait == false)
// This rotates to landscape but not single page.. it rotates all pages.
// UIDevice.CurrentDevice.SetValueForKey(new NSNumber((int)UIInterfaceOrientation.LandscapeRight), new NSString("orientation"));
// else
// UIDevice.CurrentDevice.SetValueForKey(new NSNumber((int)UIInterfaceOrientation.Portrait), new NSString("orientation"));
//}
}
}`
And one more thing to mention...
If I write GetSupportedInterfaceOrientations
in AppDelegate.cs
then my app stops working and my device is switched off automatically.
I am testing in `iPhone 5s' version 9.3.2.
Please Help !
Thank you.