8000 fix(ios-tabs): crash when add tabstrip in loaded event (#7743) · NativeScript/NativeScript@a66f2f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit a66f2f2

Browse files
authored
fix(ios-tabs): crash when add tabstrip in loaded event (#7743)
1 parent ff6d89f commit a66f2f2

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

tns-core-modules/ui/tabs/tabs.ios.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,26 +82,24 @@ class UIPageViewControllerImpl extends UIPageViewController {
8282
public viewDidLoad(): void {
8383
const owner = this._owner.get();
8484

85-
if (owner.tabStrip) {
86-
const tabBarItems = owner.tabBarItems;
87-
const tabBar = MDCTabBar.alloc().initWithFrame(this.view.bounds);
88-
89-
if (tabBarItems && tabBarItems.length) {
90-
tabBar.items = NSArray.arrayWithArray(tabBarItems);
91-
}
85+
const tabBarItems = owner.tabBarItems;
86+
const tabBar = MDCTabBar.alloc().initWithFrame(this.view.bounds);
9287

93-
tabBar.delegate = this.tabBarDelegate = MDCTabBarDelegateImpl.initWithOwner(new WeakRef(owner));
94-
tabBar.tintColor = UIColor.blueColor;
95-
tabBar.barTintColor = UIColor.whiteColor;
96-
tabBar.setTitleColorForState(UIColor.blackColor, MDCTabBarItemState.Normal);
97-
tabBar.setTitleColorForState(UIColor.blackColor, MDCTabBarItemState.Selected);
98-
tabBar.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleBottomMargin;
99-
tabBar.alignment = MDCTabBarAlignment.Leading;
100-
tabBar.sizeToFit();
101-
102-
this.tabBar = tabBar;
103-
this.view.addSubview(tabBar);
88+
if (tabBarItems && tabBarItems.length) {
89+
tabBar.items = NSArray.arrayWithArray(tabBarItems);
10490
}
91+
92+
tabBar.delegate = this.tabBarDelegate = MDCTabBarDelegateImpl.initWithOwner(new WeakRef(owner));
93+
tabBar.tintColor = UIColor.blueColor;
94+
tabBar.barTintColor = UIColor.whiteColor;
95+
tabBar.setTitleColorForState(UIColor.blackColor, MDCTabBarItemState.Normal);
96+
tabBar.setTitleColorForState(UIColor.blackColor, MDCTabBarItemState.Selected);
97+
tabBar.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleBottomMargin;
98+
tabBar.alignment = MDCTabBarAlignment.Leading;
99+
tabBar.sizeToFit();
100+
101+
this.tabBar = tabBar;
102+
this.view.addSubview(tabBar);
105103
}
106104

107105
public viewWillAppear(animated: boolean): void {
@@ -159,6 +157,8 @@ class UIPageViewControllerImpl extends UIPageViewController {
159157
}
160158

161159
this.tabBar.frame = CGRectMake(0, tabBarTop, this.tabBar.frame.size.width, tabBarHeight);
160+
} else {
161+
this.tabBar.hidden = true;
162162
}
163163

164164
const subViews: NSArray<UIView> = this.view.subviews;

0 commit comments

Comments
 (0)
0