【发布时间】:2015-02-12 16:22:26
【问题描述】:
我正在使用 UIPicker 选择图像,当用户选择时,下载将开始。我正在从我的服务器下载 78 张图像来创建动画。如何在下载图像以隐藏当前图像(imageview)以及下载完成时显示图像(imageview)时制作它。我试过了,但它不起作用。
- (void)viewDidLoad
{
[super viewDidLoad]
// Load starting image, otherwise screen is blank
self.radar_1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 65, self.view.frame.size.width, self.view.frame.size.width-70)];
radar_1.image = [UIImage animatedImageWithAnimatedGIFURL:[NSURL URLWithString:@"<|SERVER LINK|>"]];
[self.view addSubview:radar_1];
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if (row == 2) {
self.radar_1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 65, self.view.frame.size.width, self.view.frame.size.width-70)];
self.radar_1.hidden = YES;
radar_1.animationImages = [NSArray arrayWithObjects:
[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"<|SERVER LINK|> "]]],
[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"<|SERVER LINK|> "]]],
[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"<|SERVER LINK|>"]]],
[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"<|SERVER LINK|>"]]],
{...} // Doing the same 77 times...
radar_1.hidden = NO;
radar_1.animationDuration = 20.0f;
radar_1.animationRepeatCount = 0;
[radar_1 startAnimating];
[self.view addSubview: radar_1];
}
【问题讨论】:
-
你好像缺少了[super viewDidLoad]?
-
不,我只是忘了提出问题。
标签: ios uiimageview uiimage