Answer the question
In order to leave comments, you need to log in
How to implement Activity Indicator in Objective-C?
Help to implement Activity Indicator while the picture is downloading from Url.
if (self.imageView.image == nil) {
NSString *strUrl = @"http://appro.org.af/wp-content/uploads/2013/03/welcome.jpg";
NSURL *url = [NSURL URLWithString:strUrl];
NSData *dataImageUrl = [NSData dataWithContentsOfURL:url];
UIImage *imageFromUrl = [UIImage imageWithData:dataImageUrl];
if (imageFromUrl) {
[self.imageView setImage:imageFromUrl];
}
}
Answer the question
In order to leave comments, you need to log in
The library will help you
UIKit+AFNetworking
#import "UIImageView+AFNetworking.h"
/** Запускаете индикатор активности. */
[[self activitiIndicator] startAnimating];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://"]];
[[self imageView] setImageWithURLRequest:request placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
[[self imageView] setImage:image];
/** Останавливаете индикатор активности. */
[[self activitiIndicator] stopAnimating];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
/** Если возникла ошибка при загрузке. */
}];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question