fixed: settings menu safeArea adaption some times not working on iPhone

This commit is contained in:
TrueZhuanjia
2025-10-14 23:05:25 +08:00
parent 6ff2add9dd
commit 5fb4887c67
3 changed files with 21 additions and 12 deletions
@@ -402,7 +402,6 @@ BOOL isCustomResolution(int resolutionSelected) {
[self.micHandler startTapping];
*/
[self updateParentStackHorizontalConstraints];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(deviceOrientationDidChange:) // handle orientation change since i made portrait mode available
name:UIDeviceOrientationDidChangeNotification
@@ -444,6 +443,9 @@ BOOL isCustomResolution(int resolutionSelected) {
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:NO];
[self updateParentStackHorizontalConstraints];
[self updateResolutionTable];
[self.customResolutionSwitch addTarget:self action:@selector(customResolutionSwitched:) forControlEvents:UIControlEventValueChanged];
@@ -532,7 +534,14 @@ BOOL isCustomResolution(int resolutionSelected) {
if (@available(iOS 13.0, *)) {
if(parentStackWidthConstraint && parentStackLeadingConstraint) [NSLayoutConstraint deactivateConstraints:@[parentStackLeadingConstraint, parentStackWidthConstraint]];
UIInterfaceOrientation currentOrientation = keyWindow.windowScene.interfaceOrientation;
UIWindowScene *activeScene = (UIWindowScene *)[UIApplication sharedApplication].connectedScenes.allObjects.firstObject;
UIInterfaceOrientation currentOrientation;
if (activeScene.activationState == UISceneActivationStateForegroundActive) {
currentOrientation = activeScene.interfaceOrientation;
}
else currentOrientation = keyWindow.windowScene.interfaceOrientation;
switch (currentOrientation) {
case UIInterfaceOrientationLandscapeRight:
parentStackLeadingConstraint = [_parentStack.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor constant:0];