如何隐藏导航栏后退按钮? [英] How to hide navigation bar back button?

查看:221
本文介绍了如何隐藏导航栏后退按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图在Apple Watch上隐藏导航栏后退按钮。有很多类似于我的问题,但它们适用于iPhone,如果你对Apple Watch有一点了解,那就是InterfaceController而不是ViewController。

I'm trying to to hide navigation bar back button on an Apple Watch. There are a lot of questions for similar to mine but they are for iPhone and if you are know a little about Apple Watch there are InterfaceController instead of ViewController.

所以当我使用下面的代码推送一个新的InterfaceController:

So when I push a new InterfaceController using the code below:

[self pushControllerWithName:@"about" context:nil];

它在上面的导航栏上显示一个后退按钮,它将它带回到之前的InterfaceController生成。

It shows a back button on the navigation bar above and it takes it back to the previous InterfaceController from which it is generated.

任何人都知道如何隐藏或删除Apple Watch中的导航栏或此后退按钮?

Anyone have any idea how to hide or remove navigation bar or this back button from Apple Watch?

推荐答案

我遇到了同样的问题并使用以下方法解决了这个问题:

I had the same problem and solved it using :

NSMutableArray* controllerNames = [NSMutableArray new];
[controllerNames addObject:@"myInterfaceController"];
[WKInterfaceController reloadRootControllersWithNames:controllerNames contexts:myArrayOfData];

当重新加载IC时,它们没有导航后退按钮,因为它们是主IC。

When the ICs are reloaded then they don't have navigation back buttons as they are the main IC.

注意

此方法实际上会更改您的初始值您的监视应用程序的控制器(故事板中带箭头的主界面控制器。),这就是接口控制器没有后退按钮的原因。

This method actually change your Initial Controller ( Main Interface Controller with arrow in storyboard.) of your watch app, that is the reason the Interface Controller does not have back button.

这篇关于如何隐藏导航栏后退按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆