我想将活动指示器添加到图像加载图像视图上。它是如何可能的话请帮忙,谢谢如何将活动指示器添加到图像加载
我的代码
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSError *error;
NSLog(@"Error in receiving data %@",error);
NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
NSLog(@"response data %@",json);
NSArray* results = [json objectForKey:@"status"];
NSArray *imageUrlArray = [results valueForKey:@"slider_image_path"];
NSLog(@"images %@",imageUrlArray);
NSMutableArray *arrayImages = [[NSMutableArray alloc] init];
for (NSString *strImageUrl in imageUrlArray) {
[arrayImages addObject:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:strImageUrl]]]];
}
self.imageview.animationImages = arrayImages;
_imageview.animationDuration = 10;
_imageview.animationRepeatCount = 0;
[_imageview startAnimating];
}
似乎代表connectionDidFinishLoading应停止指标。开始 - 在另一个代表。或者以其他方式:启动 - 在异步数据读取任务之前,停止 - 关闭此任务。 – drewpts
@drewpts如何可能请解释 –
@ sm5345已经解释了这个想法。主要想法是在异步请求中停止指示符。因此,你不知道什么时候会完成异步任务 - 你需要在异步任务之后放置停止命令,但是完全在其中:在objc块中查看'''[removeFromSuperview]'''顺便说一下,如果你还不知道这些东西,请阅读objc中的块或swift中的闭包以及它们在异步任务中的角色。和平。 – drewpts