20

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.

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

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

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

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

4

4 回答 4

10

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

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

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

笔记

此方法实际上更改Initial Controller了您的手表应用程序(主界面控制器,情节提要中带有箭头。),这就是Interface Controller没有后退按钮的原因。

于 2015-06-18T06:00:46.160 回答
5

这是所有开拓者的 Swift 版本:

WKInterfaceController.reloadRootControllersWithNames(["myInterfaceController"], contexts: [])
于 2016-03-18T16:27:21.503 回答
1
+ (void)reloadRootControllersWithNames:(NSArray *)names contexts:(NSArray *)contexts;

但是您将失去“推”动画。

于 2015-06-19T06:45:19.850 回答
0

如果删除后退按钮,您打算如何返回上一个屏幕?

这是我对 Apple Watch 中导航按钮的观察:到目前为止,我们还没有找到任何方法来覆盖或删除后退按钮标题。即使他们提供了添加标题的选项,但无法自定义字体或任何东西。很可能当 Apple 发布原始版本时,他们会提供所有选项。

UIKit 和 WK-kit 在 UIKit 中你实际上可以使用 hidesbackbutton 属性隐藏它,但在 watch 中它会显示之前的界面控制器标题。在 UIKit 中,我们使用的是 UIViewController,但在 Watch 中使用的是 WKInterfaceController。

遗产

NSObject -> WKInterfaceController

NSObject -> UIResponder -> UIViewController

于 2015-01-19T07:03:26.737 回答