objective-c - 使用 UIModalTransitionStyleFlipHorizo​​ntal 呈现 View 时动画不起作用

标签 objective-c ios animation

我尝试用我的 View 中的图像制作动画,但它不起作用:我的图像位于没有动画的最终位置。

UIImage *myImg = [UIImage imageNamed : @"Img72.png"];
UIImageView *myImgView =[ [UIImageView alloc] initWithImage: myImg ];
myImgView.frame= CGRectMake(250,50,72,72);
[self.view addSubview:myImgView];

[UIView animateWithDuration:0.5
                      delay: 0.0
                    options: UIViewAnimationOptionCurveEaseInOut
                 animations:^{
                     [UIView setAnimationRepeatCount:100.0];
                     [UIView setAnimationRepeatAutoreverses:YES];
                     myImgView.frame= CGRectMake(50,250,72,72);
                 }
                 completion:NULL];
[myImgView release];

相同的动画代码在另一个 View 中完美运行。我终于发现它来 self 用这段代码显示 View 的方式:

FlipsideViewController *controller = [[[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil] autorelease];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; //KO
[self presentModalViewController:controller animated:YES];

问题是 modalTransitionStyle。当我评论该行(使用//KO)时,它终于起作用了。我测试了其他过渡样式和所有其他作品(UIModalTransitionStyleCoverVerticalUIModalTransitionStyleCrossDissolveUIModalTransitionStylePartialCurl)

我制作了一个viewDidLoadProject(Utility App),并在viewDidLoad 方法的两个 View 中添加了动画代码。

问题出在哪里?这是苹果的错误吗?我怎样才能让翻转过渡和我的动画在第二个 View 中工作?

这是我的示例项目:http://dl.dropbox.com/u/9204589/testFlipAnimation.zip

最佳答案

当所有系统工作完成后开始使用界面似乎更自然,我相信 didAppear 必须用于该目的(是的,它有效 :))

FlipsideViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

-(void)viewDidAppear:(BOOL)animated
{
    UIImage *myImg = [UIImage imageNamed : @"Img72.png"];
    UIImageView *myImgView =[ [UIImageView alloc] initWithImage: myImg ];
    myImgView.frame= CGRectMake(250,50,72,72);
    [self.view addSubview:myImgView];


    [UIView animateWithDuration:0.5
                          delay: 0.0
                        options: UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         [UIView setAnimationRepeatCount:100.0];
                         [UIView setAnimationRepeatAutoreverses:YES];
                         myImgView.frame= CGRectMake(50,250,72,72);
                     }
                     completion:NULL];
    [myImgView release];


    [super viewDidAppear:animated];
}

关于objective-c - 使用 UIModalTransitionStyleFlipHorizo​​ntal 呈现 View 时动画不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9777093/

相关文章:

ios - 在 iOS 13 中更改搜索栏占位符文本颜色

ios - 如何让 NSTimer 显示月份 : Weeks : Days

javascript - 许多元素的 jQuery 动画队列

ios - 每个循环后都有延迟的按钮图像阵列动画

iphone - UILocalNotification 在每个工作日重复,节假日除外

ios - 无法在 UITableViewCell 的 drawRect 中绘制

objective-c - 选定的菜单项颜色未对齐?

ios - 使用附加参数初始化隐式解包选项?

ios - 呈现 View Controller 的自定义转换不起作用

ios - 使用新的身份验证重新启动 RKObjectRequestOperation