如何从第二个视图回弹到根视图?
我在Apple Watch storyboard中使用2个模态 segue将3个视图(root,1st,2nd)连接在一起。
1)在根视图中:按下“保存”按钮后,将显示第一个模态视图
2)在第一模态视图中:按下“500”按钮后,将显示第二模态视图。 (我可以按取消按钮弹出回根视图)
3)在第二模态视图中:按下“已保存”按钮后,我想返回到根视图。 这个怎么做?
– >我不想按两次取消按钮返回根视图。
我发现只有当你的“退出”屏幕真的是根的时候才有可能。 如果不是(因为之前有屏幕),那么你不能使用下一个方法。
我正在谈论的方法是
[WKInterfaceController reloadRootControllersWithNames:(NSArray *) contexts:(NSArray *)]
当您从第二个模态中的“保存”按钮捕获操作时,请调用此方法。 它将加载您在第一个数组中指定的页面(这里您必须添加根控制器的标识符)和第二个数组的上下文(如果您希望根控制器实现它,则在此处传递一个对象第二个模态而不是被调用,因为应用程序是第一次打开)。
希望这可以帮助。
我已经实现了你的方案。
1. Use push pushControllerWithName: method to push to another view controller to navigate. Do not use present or modal to navigate to another view controller. 2. Create one NSNotificationCenter observer in your Watch first controller. 3. Create and assign WatchSession delegate in WCWatchDelegate. 4. Whenever watchsession delegate calls, post notification center. 5. Now, final step is whenever your notification method calls, use [self popToRootController]; and you will be redirect on your root controller. I have followed these step and i'm succeeded. Accept Answer if it works for you. Dont forget to vote up!!!
- 使用ios将图像转换成gif
- 尝试从苹果发现错误的示例AVCAM
- 掌握CoreData(第6部分,Core Data CRUD操作中实体之间的关系)
- Facebooklogin使用FBloginView不显示在iOS 6
- Swift:如何将点添加到封闭的CGPath?
- 在ios中动态自动扩展UITextView高度
- 我的button不检测iPhone(Retina 4英寸)模拟器上的触摸事件,但在iPhone(Retina 3.5英寸)模拟器
- 何时以及为什么要使用多个NSManagedObjectContext?
- 使用ios 11 beta 7的UIKeyboardWillShowNotification问题