ios - 从自定义转换中引用 presentingViewController

标签 ios objective-c uiviewcontroller ios7 uistoryboardsegue

我已经设置了一个自定义转换,设置为 similar to this tutorial here .

我现在要做的是更新(下方)UIViewController 上的 BOOL。这是在顶部显示 Controller 的 Controller 。

我如何获得对下面 Controller 的访问/指针?我试过 self.presentingViewController 但这指向一个 UINavigationController

自定义转换信息
底部 Controller 是 UIViewControllerTransitioningDelegate。 Controller 通过 segue 链接。以下是在 prepareForSegue 中:

self.animationController = [[MESGuessGameTurnZoomAnimation alloc] init];
UIViewController *destVC = segue.destinationViewController;    
destVC.transitioningDelegate = self;

当呈现目标 View Controller 时,用户可以单击“返回”,这将简单地运行以下(目前)以返回到原始 View Controller :

[self dismissViewControllerAnimated:YES completion:nil];

最佳答案

听起来您正试图将数据从 presentedVC 传回 presentingVC。如果是这种情况,无论您是否使用新的 iOS 7 自定义动画过渡,方法都是相同的。

您有 2 个选项,如果您使用标准过渡或自定义过渡,同样如此。

  1. 单击“返回”时使用委托(delegate)模式。这样,presentingVC 调用就会被取消,并且可以访问 presentedVC 及其任何属性。

    How do I set up a simple delegate to communicate between two view controllers?

  2. 使用展开转场。这完成了同样的事情,但使用了 Storyboard。 https://developer.apple.com/library/ios/technotes/tn2298/_index.html

您可以使用 transitioningContextprepareForSegue: 和 animationController 的 animateTransition: 方法中访问这两个 View Controller ,但我认为您只是谈论传输回数据,这可以使用上述方法之一来完成。

关于ios - 从自定义转换中引用 presentingViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21124794/

相关文章:

ios - 如果 subview (未)隐藏,则调整 View 大小

ios - AFNetworking 3.1.0 和调度组

ios - 封装核心数据对象

objective-c - CGImageRef 访问像素数据的更快方法?

ios - 当移动到另一个 View Controller 时,数据总是出现并更新

ios - Three20 - 纵向模式下的 TTSplitViewController

Java-Eclipse-WebDriver : Touch & Scroll Implementation - Automated Testing

ios - 是否可以在 iOS 应用程序中运行 XCTest 测试?

objective-c - 如何更改 MFMailComposeViewController 文本和按钮图像的颜色?

iphone - 在 iPhone 中访问/dev/tty.iap 被拒绝