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

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

问题描述

我正在尝试隐藏 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.

注意

这个方法实际上改变了你的手表应用程序的Initial Controller(主界面控制器,在storyboard中有箭头.),这就是Interface Controller没有返回的原因按钮.

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天全站免登陆