Skip to content

App crashes only on iOS 9 when changing Tabs using *ngIf and binding to SelectedIndex #1126

@NickIliev

Description

@NickIliev

From @smartsanja2013 on December 16, 2017 3:18

Which platform(s) does your issue occur on?

iOS (only on ios 9.x)

Please provide the following version numbers that your issue occurs with:

tns version 3.3.1
package.json version 3.3.0
ios version on package.json 3.0.0

Please tell us how to recreate the issue in as much detail as possible.

I have tab bar app.
There are 3 tabs
I am changing the action bar buttons based on the current selected tab index.
App crashes only on iOS 9.x (both simulator and real device) due to array out of bound index error.
Crash happens when selecting the tabs (eg: tap on 2nd tab and then try to select 1st tab, app crash)
Please see the code snippets and xCode error bellow

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

Tabs.component.html

<ActionBar [title]="title" class="action-bar" actionBarHidden="false" backgroundColor="#f33" >
    <NavigationButton visibility="collapsed"></NavigationButton>
    <ActionItem *ngIf="tabIndex!=1" (tap)="searchBtnTapped()" android.systemIcon="ic_menu_search" ios.systemIcon="12" ios.position="right"></ActionItem>
    <ActionItem *ngIf="tabIndex==2" (tap)="plusBtnTapped()" android.systemIcon="ic_input_add" ios.systemIcon="4" ios.position="right"></ActionItem>
    <ActionItem *ngIf="tabIndex==1" (tap)="deleteBtnTapped()" ios.systemIcon="16" android.systemIcon="ic_delete" ios.position="right"></ActionItem>
    <ActionItem (tap)="userBtnTapped()" android.systemIcon="ic_input_add" ios.systemIcon="4" ios.position="left"></ActionItem>
</ActionBar>

Tabs.component.ts

onSelectedIndexChanged(args: SelectedIndexChangedEventData) {
        const tabView = <TabView>args.object;
        const selectedTabViewItem = tabView.items[args.newIndex];

        this.title = selectedTabViewItem.title;
        this.tabIndex = tabView.selectedIndex;
    }

Xcode error
screen shot 2017-12-16 at 10 34 16 am

Copied from original issue: NativeScript/NativeScript#5178

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions