Nativescript behavior of the '< Go Back' button

前端 未结 2 1087
迷失自我
迷失自我 2021-01-24 01:14

I\'ve got the following ActionBar definition

相关标签:
2条回答
  • 2021-01-24 01:20

    So as @nick verified, on iOS version of {N} one cannot get the tap event of the Navigation button. I understand why {N} has to add the BACK button automatically if the navigation button is not there (because iPhones don't have a physical BACK button), but not calling an existing tap event is, IMHO, adding unnecessary differences in the framework. Here's the proposed logic for iOS.

    if NavigationButton present then if tap event handler set by user then use it else auto-gen a tap event handler else auto-gen a back-button and a tap event handler

    Anyway here's how I'm getting around this issue for my app.

    <NavigationButton visibility="collapse"/> <ActionItem ios.position="left" text="< Back" tap="onBack"/>

    This gets the behavior I expect and is cross-platform compatible with the Android version.

    0 讨论(0)
  • 2021-01-24 01:31

    UPDATE: Indeed, it appears that the NavigationButton in iOS can only be used to navigate back and can not be overridden with tap action. Reference from the NativeScript documentation

    In iOS, the back button is used explicitly for navigation. It navigates to the previous page and you cannot handle the tap event to override this behaviour.

    As for the appearing NavigationButton for iOS - it is by design just as in native iOS app. If you do not want to have back navigation you can force it with

    clearHistory: true
    

    Uncomment this line in the test application and delete the navigationButton from the sub-page and when navigation from main-page to sub-page the NavButton won't appear.

    0 讨论(0)
提交回复
热议问题