I am trying to download 5MB Image
from Server for this I want to display UIActivityIndicatorView
still Image completely downloaded and display on UIImageView
,
so how can display Activity Indicator
up to image is loaded into ImageView
?
3 回答
Use AsyncImageView .It is the better way to load images asynchronously
Place an Activity Indicator (via Interface Builder or manually) on your view. Set the property to "hide when not animating".
When doing server call, call [activityIndicator startAnimating] (IBOutlet property). When returning with actual image, call [activityIndicator stopAnimating]. When stopping, it wil automatically hide.
You can also use the activity indicator in the iPhon/Pad status bar. To do this, use [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; Set to NO for hiding it ... (obviously)
Take a look at http://blog.sallarp.com/iphone-uiimage-asynchronously/ for a sample of dl'ing an image. You would stop the activity indicator in the didReceiveData function.
MonoTouch.Dialog uses a UIActivityIndicatorView
when loading new web pages into an UIWebView
. It's fairly easy to use, see the corresponding source code here.