summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
authorMaximo Piva <maximo.piva@gmail.com>2016-05-12 07:22:11 -0300
committerRui Marinho <me@ruimarinho.net>2016-05-12 11:22:11 +0100
commit616e16a6855161693a8f30af085f37e06d5e9d67 (patch)
treed89dfe4ef7d403d5e0c21d4c81b11073b10f6a8e /Xamarin.Forms.Platform.iOS
parent82255d75d0ab4a4b311682b94f94a5d3f5d560a7 (diff)
downloadxamarin-forms-616e16a6855161693a8f30af085f37e06d5e9d67.tar.gz
xamarin-forms-616e16a6855161693a8f30af085f37e06d5e9d67.tar.bz2
xamarin-forms-616e16a6855161693a8f30af085f37e06d5e9d67.zip
Forward Orientation Methods in PlatformRenderer and ModalWrapper (#147)
* PlatformRenderer and ModalWrapper are Wrappers around the real UIViewController, rotation and orientations methods are not correctly forwarded in IOS. Per example, you cannot programatically lock the rotation of the IOS screen. This changes will fix that. * Changed spaces to tabs, as requested.
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/PlatformRenderer.cs71
1 files changed, 69 insertions, 2 deletions
diff --git a/Xamarin.Forms.Platform.iOS/PlatformRenderer.cs b/Xamarin.Forms.Platform.iOS/PlatformRenderer.cs
index 43534b2b..554c0f50 100644
--- a/Xamarin.Forms.Platform.iOS/PlatformRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/PlatformRenderer.cs
@@ -25,9 +25,43 @@ namespace Xamarin.Forms.Platform.iOS
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
{
- return UIInterfaceOrientationMask.All;
+ if ((ChildViewControllers != null) && (ChildViewControllers.Length > 0))
+ {
+ return ChildViewControllers[0].GetSupportedInterfaceOrientations();
+ }
+
+ return base.GetSupportedInterfaceOrientations();
+ }
+
+ public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation()
+ {
+ if ((ChildViewControllers != null) && (ChildViewControllers.Length > 0))
+ {
+ return ChildViewControllers[0].PreferredInterfaceOrientationForPresentation();
+ }
+ return base.PreferredInterfaceOrientationForPresentation();
}
+ public override bool ShouldAutorotate()
+ {
+ if ((ChildViewControllers != null) && (ChildViewControllers.Length > 0))
+ {
+ return ChildViewControllers[0].ShouldAutorotate();
+ }
+ return base.ShouldAutorotate();
+ }
+
+ public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)
+ {
+ if ((ChildViewControllers != null) && (ChildViewControllers.Length > 0))
+ {
+ return ChildViewControllers[0].ShouldAutorotateToInterfaceOrientation(toInterfaceOrientation);
+ }
+ return base.ShouldAutorotateToInterfaceOrientation(toInterfaceOrientation);
+ }
+
+ public override bool ShouldAutomaticallyForwardRotationMethods => true;
+
public override void ViewDidLayoutSubviews()
{
base.ViewDidLayoutSubviews();
@@ -60,9 +94,42 @@ namespace Xamarin.Forms.Platform.iOS
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
{
- return UIInterfaceOrientationMask.All;
+ if ((ChildViewControllers != null) && (ChildViewControllers.Length > 0))
+ {
+ return ChildViewControllers[0].GetSupportedInterfaceOrientations();
+ }
+ return base.GetSupportedInterfaceOrientations();
}
+ public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation()
+ {
+ if ((ChildViewControllers != null) && (ChildViewControllers.Length > 0))
+ {
+ return ChildViewControllers[0].PreferredInterfaceOrientationForPresentation();
+ }
+ return base.PreferredInterfaceOrientationForPresentation();
+ }
+
+ public override bool ShouldAutorotate()
+ {
+ if ((ChildViewControllers != null) && (ChildViewControllers.Length > 0))
+ {
+ return ChildViewControllers[0].ShouldAutorotate();
+ }
+ return base.ShouldAutorotate();
+ }
+
+ public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)
+ {
+ if ((ChildViewControllers != null) && (ChildViewControllers.Length > 0))
+ {
+ return ChildViewControllers[0].ShouldAutorotateToInterfaceOrientation(toInterfaceOrientation);
+ }
+ return base.ShouldAutorotateToInterfaceOrientation(toInterfaceOrientation);
+ }
+
+ public override bool ShouldAutomaticallyForwardRotationMethods => true;
+
public override void ViewDidAppear(bool animated)
{
Platform.DidAppear();