swift - WKInterfaceController pop() 是否删除弹出的 Controller ?

标签 swift watchkit apple-watch

我一直试图弄清楚为什么第一次推送到 WatchKit View 时它运行 didAppear() 但第二次弹出它后,它完成推送命令然后在没有运行 didAppear() 的情况下崩溃。

我一直在使用:

WKExtension.shared().rootInterfaceController.pop()

返回到上一个 View 。这是删除弹出的 View 吗?如果是这样,有没有办法保存 View 以便我可以再次推送它? pop() 不返回 View 。

最佳答案

问题是您正在弹出(从导航堆栈中删除)根界面 Controller 而不是当前界面 Controller 。您基本上是在尝试删除推送所有其他 Controller 的接口(interface) Controller 。想象一下,如果您正在 build 一座叠叠乐塔,并且不是从顶部移除一 block 砖,而是移除了底部的一 block 。当然你的塔会折叠。

根据您实际想要实现的目标,您需要在当前界面 Controller 中调用 self.pop()self.popToRootController() 。如果导航堆栈上有两个以上的界面 Controller ,前者只会移回到前一个 Controller ,而无论堆栈中有多少个界面 Controller ,后者都将始终返回到根界面 Controller 。

关于swift - WKInterfaceController pop() 是否删除弹出的 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45624995/

相关文章:

ios - 使用 MMDrawerController 时检测抽屉何时关闭

ios - WKInterfacePicker 列表中的图片样式

watchkit - watch 加载屏幕上的自定义品牌

ios - 如何减少 WKInterfaceTable 中的行间距

ios - 在 WatchKit 中使用应用内购买功能来获得一目了然的功能和复杂功能

ios - Swift Game Center 保存高分功能不起作用

ios - 如何从 UIAlertcontroller 中关闭模态 ViewController

arrays - 过滤具有特定名称的所有结构的数组并将其删除

ios - 包含 iOS 应用程序数据更改时更新 WatchKit 应用程序

ios - 如何使用 iOS WatchKit 将 WKInterfaceButton 的标题文本居中