| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ import { ViewBase } from "../view-base"; | |||
| 4 | 4 | ||
| 5 | 5 | import { | |
| 6 | 6 | ViewCommon, layout, isEnabledProperty, originXProperty, originYProperty, automationTextProperty, isUserInteractionEnabledProperty, | |
| 7 | - traceEnabled, traceWrite, traceCategories | ||
| 7 | + traceEnabled, traceWrite, traceCategories, traceMessageType | ||
| 8 | 8 | } from "./view-common"; | |
| 9 | 9 | ||
| 10 | 10 | import { ios as iosBackground, Background } from "../../styling/background"; | |
@@ -615,17 +615,24 @@ export namespace ios { | |||
| 615 | 615 | export function updateConstraints(controller: UIViewController, owner: View): void { | |
| 616 | 616 | const root = controller.view; | |
| 617 | 617 | if (!root.safeAreaLayoutGuide) { | |
| 618 | - const layoutGuide = (<any>root).safeAreaLayoutGuide = UILayoutGuide.alloc().init(); | ||
| 619 | - root.addLayoutGuide(layoutGuide); | ||
| 620 | - NSLayoutConstraint.activateConstraints(<any>[ | ||
| 621 | - layoutGuide.topAnchor.constraintEqualToAnchor(controller.topLayoutGuide.bottomAnchor), | ||
| 622 | - layoutGuide.bottomAnchor.constraintEqualToAnchor(controller.bottomLayoutGuide.topAnchor), | ||
| 623 | - layoutGuide.leadingAnchor.constraintEqualToAnchor(root.leadingAnchor), | ||
| 624 | - layoutGuide.trailingAnchor.constraintEqualToAnchor(root.trailingAnchor) | ||
| 625 | - ]); | ||
| 618 | + const layoutGuide = initLayoutGuide(controller); | ||
| 619 | + (<any>controller.view).safeAreaLayoutGuide = layoutGuide; | ||
| 626 | 620 | } | |
| 627 | 621 | } | |
| 628 | 622 | ||
| 623 | + function initLayoutGuide(controller: UIViewController) { | ||
| 624 | + const rootView = controller.view; | ||
| 625 | + const layoutGuide = UILayoutGuide.alloc().init(); | ||
| 626 | + rootView.addLayoutGuide(layoutGuide); | ||
| 627 | + NSLayoutConstraint.activateConstraints(<any>[ | ||
| 628 | + layoutGuide.topAnchor.constraintEqualToAnchor(controller.topLayoutGuide.bottomAnchor), | ||
| 629 | + layoutGuide.bottomAnchor.constraintEqualToAnchor(controller.bottomLayoutGuide.topAnchor), | ||
| 630 | + layoutGuide.leadingAnchor.constraintEqualToAnchor(rootView.leadingAnchor), | ||
| 631 | + layoutGuide.trailingAnchor.constraintEqualToAnchor(rootView.trailingAnchor) | ||
| 632 | + ]); | ||
| 633 | + return layoutGuide; | ||
| 634 | + } | ||
| 635 | + | ||
| 629 | 636 | function getStatusBarHeight(viewController?: UIViewController): number { | |
| 630 | 637 | const app = iosUtils.getter(UIApplication, UIApplication.sharedApplication); | |
| 631 | 638 | if (!app || app.statusBarHidden) { | |
@@ -646,7 +653,15 @@ export namespace ios { | |||
| 646 | 653 | const frame = controller.view.frame; | |
| 647 | 654 | const fullscreenOrigin = frame.origin; | |
| 648 | 655 | const fullscreenSize = frame.size; | |
| 649 | - const safeArea = controller.view.safeAreaLayoutGuide.layoutFrame; | ||
| 656 | + | ||
| 657 | + let layoutGuide = controller.view.safeAreaLayoutGuide; | ||
| 658 | + if (!layoutGuide) { | ||
| 659 | + traceWrite(`safeAreaLayoutGuide during layout of ${owner}. Creating fallback constraints, but layout might be wrong.`, | ||
| 660 | + traceCategories.Layout, traceMessageType.error); | ||
| 661 | + | ||
| 662 | + layoutGuide = initLayoutGuide(controller); | ||
| 663 | + } | ||
| 664 | + const safeArea = layoutGuide.layoutFrame; | ||
| 650 | 665 | const safeOrigin = safeArea.origin; | |
| 651 | 666 | const safeAreaSize = safeArea.size; | |
| 652 | 667 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments