mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-04-20 23:40:17 +00:00
Fix race condition that could cause safe area insets to be missing
This commit is contained in:
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
@implementation SettingsViewController {
|
@implementation SettingsViewController {
|
||||||
NSInteger _bitrate;
|
NSInteger _bitrate;
|
||||||
Boolean _adjustedForSafeArea;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@dynamic overrideUserInterfaceStyle;
|
@dynamic overrideUserInterfaceStyle;
|
||||||
@@ -89,21 +88,21 @@ static const int bitrateTable[] = {
|
|||||||
self.scrollView.contentSize = CGSizeMake(self.scrollView.contentSize.width,
|
self.scrollView.contentSize = CGSizeMake(self.scrollView.contentSize.width,
|
||||||
highestViewY + 20);
|
highestViewY + 20);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adjust the subviews for the safe area on the iPhone X.
|
||||||
|
- (void)viewSafeAreaInsetsDidChange {
|
||||||
|
[super viewSafeAreaInsetsDidChange];
|
||||||
|
|
||||||
// Adjust the subviews for the safe area on the iPhone X.
|
if (@available(iOS 11.0, *)) {
|
||||||
if (!_adjustedForSafeArea) {
|
for (UIView* view in self.view.subviews) {
|
||||||
if (@available(iOS 11.0, *)) {
|
// HACK: The official safe area is much too large for our purposes
|
||||||
for (UIView* view in self.view.subviews) {
|
// so we'll just use the presence of any safe area to indicate we should
|
||||||
// HACK: The official safe area is much too large for our purposes
|
// pad by 20.
|
||||||
// so we'll just use the presence of any safe area to indicate we should
|
if (self.view.safeAreaInsets.left >= 20 || self.view.safeAreaInsets.right >= 20) {
|
||||||
// pad by 20.
|
view.frame = CGRectMake(view.frame.origin.x + 20, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
|
||||||
if (self.view.safeAreaInsets.left >= 20 || self.view.safeAreaInsets.right >= 20) {
|
|
||||||
view.frame = CGRectMake(view.frame.origin.x + 20, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_adjustedForSafeArea = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user