我正在尝试在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];
有谁能告诉我这里做错了什么?
答案 0 :(得分: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];
设置此帧大小,它工作正常。我希望它会对你有所帮助。感谢