• <tfoot id='z6J0e'></tfoot>
    <i id='z6J0e'><tr id='z6J0e'><dt id='z6J0e'><q id='z6J0e'><span id='z6J0e'><b id='z6J0e'><form id='z6J0e'><ins id='z6J0e'></ins><ul id='z6J0e'></ul><sub id='z6J0e'></sub></form><legend id='z6J0e'></legend><bdo id='z6J0e'><pre id='z6J0e'><center id='z6J0e'></center></pre></bdo></b><th id='z6J0e'></th></span></q></dt></tr></i><div id='z6J0e'><tfoot id='z6J0e'></tfoot><dl id='z6J0e'><fieldset id='z6J0e'></fieldset></dl></div>

    <small id='z6J0e'></small><noframes id='z6J0e'>

    <legend id='z6J0e'><style id='z6J0e'><dir id='z6J0e'><q id='z6J0e'></q></dir></style></legend>

        <bdo id='z6J0e'></bdo><ul id='z6J0e'></ul>
      1. 如何一次弹出模态视图和前一个导航控制器视图?

        How can I pop a modal view and the previous navigation controller view at once?(如何一次弹出模态视图和前一个导航控制器视图?)
        • <small id='TZ170'></small><noframes id='TZ170'>

            <tbody id='TZ170'></tbody>
        • <i id='TZ170'><tr id='TZ170'><dt id='TZ170'><q id='TZ170'><span id='TZ170'><b id='TZ170'><form id='TZ170'><ins id='TZ170'></ins><ul id='TZ170'></ul><sub id='TZ170'></sub></form><legend id='TZ170'></legend><bdo id='TZ170'><pre id='TZ170'><center id='TZ170'></center></pre></bdo></b><th id='TZ170'></th></span></q></dt></tr></i><div id='TZ170'><tfoot id='TZ170'></tfoot><dl id='TZ170'><fieldset id='TZ170'></fieldset></dl></div>
          <legend id='TZ170'><style id='TZ170'><dir id='TZ170'><q id='TZ170'></q></dir></style></legend>
            • <bdo id='TZ170'></bdo><ul id='TZ170'></ul>

                  <tfoot id='TZ170'></tfoot>

                1. 本文介绍了如何一次弹出模态视图和前一个导航控制器视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想同时弹出一个模态视图和上一个视图.例如,查看日历应用程序.当我在 Edit 屏幕上并选择 Delete Event 时,我将返回日历视图.

                  I want to pop a modal view and the previous view at the same time. For example, look at the calendars app. When I am on the Edit screen and select Delete Event, I am taken back to the calendar view.

                  Edit 屏幕和 Event 屏幕(用户只是在其中查看日历事件)以模态方式显示.我遇到的问题是我知道如何弹出模态视图,但来自同一个 UIViewController 子类(本例中为 Edit 屏幕).

                  The Edit screen, which was presented modally is popped as well as the the Event screen (where the user is just viewing the calendar event). The problem I am having is that I know how to pop a modal view, but from the same UIViewController subclass (Edit screen in this example).

                  如何弹出非模态视图?

                  我正在考虑像往常一样弹出模式视图,然后将 NSNotification 发布到Event"(例如)屏幕的 UIViewController 子类并告诉它也弹出该视图.

                  I was thinking about popping the modal view as you would normally, then posting a NSNotification to the 'Event' (for instance) screen's UIViewController subclass and telling it to pop that view as well.

                  另外,对于动画来说,应该是dismissModalViewControllerAnimated动画(向下滑动)而不是popViewControllerAnimated动画(向左滑动).

                  The other thing is that for the animation, it should be the dismissModalViewControllerAnimated animation (slide down) and not the popViewControllerAnimated animation (slide left).

                  寻找更好的解决方案,我发现 this,这在我的情况下不起作用(至少对于 popViewControllerAnimated.

                  Looking for a better solution, I found this, which doesn't work in my case (at least not with popViewControllerAnimated.

                  推荐答案

                  您需要使用委托模式通知模态父级"它应该关闭模态视图控制器(动画:NO)并将自己从堆栈中弹出(动画:是).

                  You need to use the delegate pattern to notify the modal "parent" that it should dismiss the modal view controller (animated:NO) and pop itself off the stack (animated:YES).

                  这正是日历应用程序上发生的情况 - 只需注意确认事件删除时导航栏标题发生的情况 - 您可以看到标题快速从编辑"变为事件详细信息"作为该视图正在从导航堆栈中弹出.

                  This is exactly what happens on the Calendar App - just pay attention to what happens to the navigation bar title when you confirm an event deletion - you can see the title quickly changing from "Edit" to "Event Details" as that view is being popped out off the navigation stack.

                  所以简而言之,如果我们在谈论日历应用程序,在您的模态视图控制器中,使用 didConfirmEventDeletion 之类的方法创建一个协议:

                  So in a nutshell, if we were talking about the calendar app, in your modal view controller, create a protocol with a method like didConfirmEventDeletion:

                  @protocol ModalViewDelegate <NSObject>
                  - (void)didConfirmEventDeletion;
                  @end
                  
                  @interface ModalViewController...
                  
                  @property (nonatomic, assign) id<ModalViewDelegate> delegate;
                  
                  @end     
                  

                  及实施:

                  @implementation ModalViewController
                  
                  - (void)deleteEventMethod
                  {
                      ...
                      if ([self.delegate respondsToSelector:@selector(didConfirmEventDeletion)])
                           [self.delegate didConfirmEventDeletion];
                  }
                  

                  然后在您的父视图控制器中,将自己声明为模态的委托并实现 didConfirmEventDeletion:

                  Then in your parent view controller, declare itself as the delegate for the modal and implement didConfirmEventDeletion:

                  - (void)didConfirmEventDeletion
                  {
                      [self dismissModalViewControllerAnimated:NO];
                      [self.navigationController popViewControllerAnimated:YES];
                  }
                  

                  PS:我写这段代码时可能有一些拼写错误...

                  PS: there might be a few typos as I wrote this code off memory...

                  这篇关于如何一次弹出模态视图和前一个导航控制器视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  UINavigationController inside a UITabBarController inside a UISplitViewController presented modally on iPhone(UISplitViewController 内的 UITabBarController 内的 UINavigationController 以模态方式呈现在 iPhone 上) - IT屋-程序员软件开发技术分
                  ViewController in UINavigationController orientation change(UINavigationController 中的 ViewController 方向更改)
                  Custom back button in UINavigationController(UINavigationController 中的自定义后退按钮)
                  How to add a navigation controller programmatically in code but not as initial view controller(如何在代码中以编程方式添加导航控制器,但不作为初始视图控制器)
                  How to get the previous viewcontroller that pushed my current view(如何获取推送我当前视图的上一个视图控制器)
                  The correct way to set a light status bar text color in iOS 7 based on different ViewControllers(iOS 7中基于不同ViewControllers设置灯光状态栏文字颜色的正确方法)
                    <bdo id='yJD4L'></bdo><ul id='yJD4L'></ul>
                    • <small id='yJD4L'></small><noframes id='yJD4L'>

                          <tbody id='yJD4L'></tbody>
                        <legend id='yJD4L'><style id='yJD4L'><dir id='yJD4L'><q id='yJD4L'></q></dir></style></legend>
                          <tfoot id='yJD4L'></tfoot>
                          <i id='yJD4L'><tr id='yJD4L'><dt id='yJD4L'><q id='yJD4L'><span id='yJD4L'><b id='yJD4L'><form id='yJD4L'><ins id='yJD4L'></ins><ul id='yJD4L'></ul><sub id='yJD4L'></sub></form><legend id='yJD4L'></legend><bdo id='yJD4L'><pre id='yJD4L'><center id='yJD4L'></center></pre></bdo></b><th id='yJD4L'></th></span></q></dt></tr></i><div id='yJD4L'><tfoot id='yJD4L'></tfoot><dl id='yJD4L'><fieldset id='yJD4L'></fieldset></dl></div>