Dim noPage As NativeObject = pPage
Dim window As NativeObject
window = noPage.GetField("window")
If window.IsInitialized = False Then
Return
End If
Dim windowScene As NativeObject
windowScene = window.GetField("windowScene")
If windowScene.IsInitialized = False Then
Return
End If
If pbolLocked = False Then
' Unlock orientation
Dim prefUnlock As NativeObject
prefUnlock.Initialize("UIWindowSceneGeometryPreferencesIOS")
prefUnlock = prefUnlock.RunMethod("alloc", Null)
windowScene.RunMethod("requestGeometryUpdateWithPreferences:errorHandler:", Array(prefUnlock, Null))
Return
End If
' Lock orientation
Dim mask As Int
Select getOrientation
Case ORIENTATION_PORTRAIT
mask = 1
Case ORIENTATION_LANDSCAPE
mask = 3
Case ORIENTATION_LANDSCAPE_RIGHT
mask = 4
Case Else
mask = 0
End Select
Dim prefLock As NativeObject
prefLock.Initialize("UIWindowSceneGeometryPreferencesIOS")
prefLock = prefLock.RunMethod("alloc", Null)
prefLock = prefLock.RunMethod("initWithInterfaceOrientations:", Array(mask))
windowScene.RunMethod("requestGeometryUpdateWithPreferences:errorHandler:", Array(prefLock, Null))