1

我正在尝试在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];

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

4

1 回答 1

1

这是由于您的动画 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];

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

于 2013-05-27T05:18:36.180 回答