I get the image url
from webservice,i has loaded that image in imageview
.Like as follows..
[ImageName setImageWithURL:[NSURL URLWithString:[[NSString stringWithFormat:@"image url"]stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding ]]].
It has taking time to load image in imageview
. I want to display activity indicator before loading image in imageview
.
You could do it this way :
Add an indicator to your view, place it at the center of your imageview
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[indicator startAnimating];
[indicator setCenter:self.imageView.center];
[self.contentView addSubview:indicator];
Remove the indicator from the superview in the block's succes method.
NSUrl *anURL=[NSURL URLWithString:[[NSString stringWithFormat:@"image url"]stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding ]];
[_imageView setImageWithURL:[NSURL URLWithString:anURL]
success:^(UIImage *image) {
[indicator removeFromSuperview];
}
failure:^(NSError *error) {
}];
}
Of course you could make a nice subclass for this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With