gpt4 book ai didi

ios - UIAlertView 中的动画图像

转载 作者:行者123 更新时间:2023-11-29 13:12:47 24 4
gpt4 key购买 nike

我正在尝试在 UIAlertView 中播放图像动画。

这是我的代码:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];

UIImageView *animation = nil;
animation.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"Comment-Edit-48.png"],[UIImage imageNamed:@"Share-48.png"],[UIImage imageNamed:@"Comment-Edit-48.png"],[UIImage imageNamed:@"Play-48.png"], nil];
[animation setAnimationRepeatCount:10];
animation.animationDuration = 1.5;
[animation startAnimating];

[alert addSubview:animation];


[alert show];
[alert release];

谁能告诉我我在这里做错了什么?

最佳答案

这是由于您的动画 imageView 帧大小。您需要使用动画 imageView 的特定帧大小来分配它。如果你不这样做,那么它不会占用任何内存空间。将在 UIAlertView 中添加一个 nil 对象。在给定的代码下面试试这个

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];

UIImageView *animation =[[UIImageView alloc] initWithFrame:CGRectMake(120, 50, 50, 45)];
animation.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"Comment-Edit-48.png"],[UIImage imageNamed:@"Share-48.png"],[UIImage imageNamed:@"Comment-Edit-48.png"],[UIImage imageNamed:@"Play-48.png"], nil];
[animation setAnimationRepeatCount:10];
animation.animationDuration = 1.5;
[animation startAnimating];

[alert addSubview:animation];


[alert show];
[alert release];

设置此帧大小,它工作正常。我希望它能帮助你。谢谢

关于ios - UIAlertView 中的动画图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16765869/

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