我有以下 ActionBar 定义
<ActionBar class="action-bar" title="Settings">
<NavigationButton text="Go Back" android.systemIcon="ic_menu_back" tap="onBackTap"/>
</ActionBar>
Android 版本确实被调用。
在 iOS 版本中 - onBackTap 方法永远不会被调用。
而且在 iOS 版本中,即使导航按钮条目不存在,{N} 也会自动插入一个。
最佳答案
更新: 事实上,iOS 中的 NavigationButton 似乎只能用于向后导航,并且不能用 tap 操作覆盖。引用自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.
至于出现的 iOS 导航按钮 - 它的设计与 native iOS 应用程序一样。如果您不想后退导航,可以使用
强制它clearHistory: true
取消注释this line在测试应用程序中,并从子页面
中删除navigationButton,并且当从main-page
导航到子页面
时,NavButton将不会出现。
关于 '< Go Back' 按钮的 Nativescript 行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41863216/