I'm from RN background and pretty new to Objective-C/Swift. Though it is RN project, but there are lot of implementation written by previous engineers in Objective-C/Swift. This particular implementation was written in Objective-C which is to lock the screen in both portrait and landscape. But the problem here the landscape mode doesn't work for iOS 16.
Upon reading through the docs I discover that iOS 16 uses requestGeometryUpdateWithPreferences which our code need to be updated based on that. I've been looking around for the solution in Objective-C and I found this partial solution and the solution in Swift.
I thought of using the partial solution above with the my little update to define the deviceOrientation. But I know it won't work and is incorrect with the code below. What can I try next?
UIInterfaceOrientation deviceOrientation = [UIApplication sharedApplication].statusBarOrientation;
UIWindowScene *windowScene = ( UIWindowScene *)[[[ UIApplication sharedApplication] connectedScenes] allObjects].firstObject;
UIWindowSceneGeometryPreferencesIOS *perference = [[ UIWindowSceneGeometryPreferencesIOS alloc] init];
perference.interfaceOrientations = 1 < deviceOrientation;
[windowScene requestGeometryUpdateWithPreferences:perference errorHandler: ^( NSError * _Nonnull error) {
NSLog(@ "error--%@", error);
}];