Skip to content

Commit 05f802b

Browse files
committed
Merge pull request NativeScript#2124 from NativeScript/raikov/fix-2084
Fixed: App crashes when animating ActionBar
2 parents 5d28b1e + 6075a83 commit 05f802b

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

ui/action-bar/action-bar.ios.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,21 @@ export class NavigationButton extends ActionItem {
2929
}
3030

3131
export class ActionBar extends common.ActionBar {
32-
public update() {
32+
33+
get ios(): UIView {
34+
35+
if (!(this.page && this.page.parent)) {
36+
return;
37+
}
38+
39+
let viewController = (<UIViewController>this.page.ios);
40+
if (viewController.navigationController !== null) {
41+
return viewController.navigationController.navigationBar;
42+
}
43+
return null;
44+
}
45+
46+
public update() {
3347
// Page should be attached to frame to update the action bar.
3448
if (!(this.page && this.page.parent)) {
3549
return;
@@ -38,7 +52,7 @@ export class ActionBar extends common.ActionBar {
3852
var viewController = (<UIViewController>this.page.ios);
3953
var navigationItem: UINavigationItem = viewController.navigationItem;
4054
var navController = frameModule.topmost().ios.controller;
41-
var navigationBar = <UINavigationBar>navController.navigationBar;
55+
var navigationBar = navController ? <UINavigationBar>navController.navigationBar : null;
4256
var previousController: UIViewController;
4357

4458
// Set Title
@@ -53,7 +67,7 @@ export class ActionBar extends common.ActionBar {
5367
if (indexOfViewController < navController.viewControllers.count && indexOfViewController > 0) {
5468
previousController = navController.viewControllers[indexOfViewController - 1];
5569
}
56-
70+
5771
// Set back button text
5872
if (previousController) {
5973
if (this.navigationButton) {
@@ -250,6 +264,10 @@ export class ActionBar extends common.ActionBar {
250264
super.onLayout(left, top, right, bottom);
251265
}
252266

267+
public layoutNativeView(left: number, top: number, right: number, bottom: number) {
268+
return;
269+
}
270+
253271
public _shouldApplyStyleHandlers() {
254272
var topFrame = frameModule.topmost();
255273
return !!topFrame;

0 commit comments

Comments
 (0)