Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
NavControl.ShowPage(Page1)
Dim no As NativeObject = Me
no.RunMethod("addListener", Null)
End Sub
#if OBJC
- (void)addListener {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_orientation_changed)
name:UIDeviceOrientationDidChangeNotification object:nil];
}
#end if
Private Sub Orientation_Changed
Log($"Current orientation: ${DeviceOrientation}"$)
End Sub
Private Sub DeviceOrientation As String
Dim no As NativeObject
Dim o As Int = no.Initialize("UIDevice").RunMethod("currentDevice", Null).RunMethod("orientation", Null).AsNumber
Select o
Case 0
Return "Unknown"
Case 1
Return "Portrait"
Case 2
Return "PortraitUpsideDown"
Case 3
Return "LandscapeLeft"
Case 4
Return "LandscapeRight"
Case 5
Return "FaceUp"
Case 6
Return "FaceDown"
End Select
Return "Unknown"
End Sub