在prepareForSegue 中的viewControllers 之间传递动画UIImageView:? [英] Passing an animating UIImageView between viewControllers in prepareForSegue:?

查看:26
本文介绍了在prepareForSegue 中的viewControllers 之间传递动画UIImageView:?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于之前的一些问题(例如:ios5 如何通过 prepareForSegue:aUIImageView) 我想知道这种技术有多流畅,比如在使用动画 = NO 进行模态转场时.

Based on some earlier questions (ex: ios5 how to pass prepareForSegue: a UIImageView) I was wondering how smooth this technique is, say when doing a modal segue with animated = NO.

我可以拼凑一个测试,但我想有人已经研究了使用它作为过渡技术的性能和实际陷阱.我有兴趣了解任何细节 - 例如,UIImageView 动画是重新启动还是继续快速播放?

I can toss together a test but I imagine someone has already scoped out the performance and practical pitfalls of using this as a transition technique. I would be interested in hearing any details - for example, does the UIImageView animation restart or does it continue apace?

推荐答案

如果您将动画图像视图传递给另一个控制器,看起来动画会继续快速播放.我在动画中看不到任何故障".继续进行模态演示工作正常.我无法回到第一个控制器,仅仅通过解除,我不得不将图像视图添加回视图以使其工作,即使这样它也只有在我关闭自动布局时才有效(否则我会收到错误提示它不能安装约束).所以,为了使用模态(没有动画)来回切换,我在第一个控制器中有这个:

If you pass an animating image view to another controller, it looks like the animation continues apace. I can't see any "hitch" in the animation. Going forward with a modal presentation worked fine. I couldn't go back to the first controller, by just dismissing, I had to add the image view back to the view to make that work, and even then it only worked if I turned off auto layout (otherwise I get an error saying it can't install a constraint). So, to go back and forth with modals (with no animation) I had this in the first controller:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.isFirst = YES;
    NSMutableArray *imgArray = [NSMutableArray array];
    for (int i = 1; i< 41; i++) {
        UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"New_PICT%04d.jpg",i]];
        if (img) {
            [imgArray addObject:img];
        }
    }
    self.iv.animationImages = imgArray;
    self.iv.animationDuration = 10;
    [self.iv startAnimating];
}

-(void)viewDidAppear:(BOOL)animated {
    if (self.isFirst) {
        self.isFirst = NO;
    }else{
        self.iv.frame = CGRectMake(48, 48, 48, 48);
        [self.view addSubview:self.iv];
    }
}


-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    SecondViewController *sec = segue.destinationViewController;
    sec.iv = self.iv;
}

这篇关于在prepareForSegue 中的viewControllers 之间传递动画UIImageView:?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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