This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree 2 files changed +17
-20
lines changed
shell/platform/darwin/ios/framework/Source
2 files changed +17
-20
lines changed Original file line number Diff line number Diff line change @@ -1544,21 +1544,17 @@ - (void)performOrientationUpdate:(UIInterfaceOrientationMask)new_preferences {
1544
1544
continue ;
1545
1545
}
1546
1546
UIWindowScene* windowScene = (UIWindowScene*)scene;
1547
- UIInterfaceOrientationMask currentInterfaceOrientation =
1548
- 1 << windowScene.interfaceOrientation ;
1549
- if (!(_orientationPreferences & currentInterfaceOrientation)) {
1550
- [self setNeedsUpdateOfSupportedInterfaceOrientations ];
1551
- UIWindowSceneGeometryPreferencesIOS* preference =
1552
- [[UIWindowSceneGeometryPreferencesIOS alloc ]
1553
- initWithInterfaceOrientations: _orientationPreferences];
1554
- [windowScene
1555
- requestGeometryUpdateWithPreferences: preference
1556
- errorHandler: ^(NSError * error) {
1557
- os_log_error (OS_LOG_DEFAULT,
1558
- " Failed to change device orientation: %@" ,
1559
- error);
1560
- }];
1561
- }
1547
+ UIWindowSceneGeometryPreferencesIOS* preference =
1548
+ [[UIWindowSceneGeometryPreferencesIOS alloc ]
1549
+ initWithInterfaceOrientations: _orientationPreferences];
1550
+ [windowScene
1551
+ requestGeometryUpdateWithPreferences: preference
1552
+ errorHandler: ^(NSError * error) {
1553
+ os_log_error (OS_LOG_DEFAULT,
1554
+ " Failed to change device orientation: %@" ,
1555
+ error);
1556
+ }];
1557
+ [self setNeedsUpdateOfSupportedInterfaceOrientations ];
1562
1558
}
1563
1559
} else {
1564
1560
UIInterfaceOrientationMask currentInterfaceOrientation =
Original file line number Diff line number Diff line change @@ -891,13 +891,17 @@ - (void)orientationTestWithOrientationUpdate:(UIInterfaceOrientationMask)mask
891
891
id mockApplication = OCMClassMock ([UIApplication class ]);
892
892
id mockWindowScene;
893
893
id deviceMock;
894
+ FlutterViewController* realVC = [[FlutterViewController alloc ] initWithEngine: self .mockEngine
895
+ nibName: nil
896
+ bundle: nil ];
894
897
if (@available (iOS 16.0 , *)) {
895
898
mockWindowScene = OCMClassMock ([UIWindowScene class ]);
896
- OCMStub ([mockWindowScene interfaceOrientation ]).andReturn (currentOrientation);
897
- if (!didChange) {
899
+ if (realVC.supportedInterfaceOrientations == mask) {
898
900
OCMReject ([mockWindowScene requestGeometryUpdateWithPreferences: [OCMArg any ]
899
901
errorHandler: [OCMArg any ]]);
900
902
} else {
903
+ // iOS 16 will decide whether to rotate based on the new preference, so always set it
904
+ // when it changes.
901
905
OCMExpect ([mockWindowScene
902
906
requestGeometryUpdateWithPreferences: [OCMArg checkWithBlock: ^BOOL (
903
907
UIWindowSceneGeometryPreferencesIOS*
@@ -919,9 +923,6 @@ - (void)orientationTestWithOrientationUpdate:(UIInterfaceOrientationMask)mask
919
923
OCMStub ([mockApplication sharedApplication ]).andReturn (mockApplication);
920
924
OCMStub ([mockApplication statusBarOrientation ]).andReturn (currentOrientation);
921
925
}
922
- FlutterViewController* realVC = [[FlutterViewController alloc ] initWithEngine: self .mockEngine
923
- nibName: nil
924
- bundle: nil ];
925
926
926
927
[realVC performOrientationUpdate: mask];
927
928
if (@available (iOS 16.0 , *)) {
You can’t perform that action at this time.
0 commit comments