gpt4 book ai didi

ios - 自定义 IOS7 转换将数据传递给呈现 View Controller

转载 作者:行者123 更新时间:2023-11-29 03:20:58 24 4
gpt4 key购买 nike

我正在考虑实现一些自定义 IOS7 转换。对于 example these here .

在此示例中按下按钮时,将运行以下命令:

-(void)showNewController:(id)sender{

UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:[NSBundle mainBundle]];
UIViewController* controller = [storyboard instantiateViewControllerWithIdentifier:@"PresentedViewController"];

if(sender == self.button1){
self.animationController = [[ZoomAnimationController alloc] init];
}else{
self.animationController = [[DropAnimationController alloc] init];
}

controller.transitioningDelegate = self;
[self presentViewController:controller animated:YES completion:nil];
}

问题
我试图了解将信息传递给新的 UIViewController 的正确位置。举个例子,假设我正在尝试将 UIImage 传递给新的(将要)呈现的 View Controller 。

通常我会在 prepareForSegue 方法中完成此操作,但由于这不是一个 segue,所以传递数据的正确方法是什么。

我可以简单地添加以下示例:

controller.passingImage = self.imageToPass;

在 IOS7 中使用自定义过渡时,这是否是正确的流程?

最佳答案

当您在 iOS 7 中使用新的自定义动画过渡时,您设置 View Controller 的方式不会改变。因此,如果您使用 Storyboard,您仍然需要在prepareForSegue中设置 View Controller (包括设置transitioningDelegate)。

有关使用 Storyboard 的自定义动画过渡示例,请参阅以下示例代码。它是 WWDC session 218 的示例代码的实现:使用 View Controller 的自定义转换。查看 SOLViewController.m 以开始使用。

https://github.com/soleares/SOLPresentingFun

关于ios - 自定义 IOS7 转换将数据传递给呈现 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21103118/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com