如何从第二视图弹出回到根视图? [英] How to pop back to root view from a 2nd view?

查看:119
本文介绍了如何从第二视图弹出回到根视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用Apple Watch故事板上的2个 modal 链接将3个视图(root,1st,2nd)连接在一起.

I have connected 3 views (root, 1st, 2nd) together using 2 modal segues in apple watch storyboard.

1)在根视图中:按下保存"按钮后,将显示第一个模态视图

1) In root view: Once the "save" button is pressed, 1st modal view will be displayed

2)在第一模式视图中:按下"500"按钮后,将显示第二模式视图. (我可以按取消"按钮跳回到根视图)

2) In 1st modal view: Once the "500" button is pressed, 2nd modal view will be displayed. (I can press cancel button to pop back to root view)

3)在第二模式视图中:按下保存"按钮后,我想返回到根视图.该怎么做?

3) In 2nd modal view: Once the "saved" button is pressed, I want to go back to root view. How to do this?

->我不想按两次取消"按钮返回到根视图.

--> I don't want to press cancel button twice to go back to the root view.

推荐答案

我发现只有在您的注销"屏幕确实是根目录的情况下,这才是可行的.如果不是(因为之前有屏幕),则不能使用下一种方法.

I found this is posible only if your "Logout" screen is really the root. If it is not (because there were screens before it) then you can not use the next method.

我在说的方法是

[WKInterfaceController reloadRootControllersWithNames:(NSArray *) contexts:(NSArray *)]

当您从第二个模式中的保存"按钮捕获动作时,调用此方法.它将使用第二个数组的上下文加载您在第一个数组中指定的页面(在这里您必须添加根控制器的标识符)(如果您希望您的根控制器意识到它是从对象中调用的,则在此处交付一个对象).第二种模式,而不是因为第一次打开该应用而被调用).

Call this method when you catch the action from your "Save" button in your second modal. It will load the pages you specify in the first array (here you have to add the identifier of your root controller) with the contexts of the second array (here you deliver an object if you want your root controller to realize it was called from the second modal instead of being called because the app is opened by the first time).

希望这会有所帮助.

这篇关于如何从第二视图弹出回到根视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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