I am using http communication in My iPhone app. I want to show a progress bar while it is loading data from server. How can I do it programmatically?
I just want a d
App Delegate.h
-(void)showLoader;
-(void)hideLoder;
App Delegate.m
@implementation AppDelegate
AppDelegate *app;
-(void)showLoader
{
if(loaderView== NULL)
{
loaderView=[[UIView alloc] initWithFrame:self.window.frame];
[loaderView setBackgroundColor:[UIColor blackColor]];
[loaderView setAlpha:0.5];
spinner = [[UIActivityIndicatorView alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[loaderView addSubview:spinner];
spinner.center = CGPointMake(loaderView.frame.size.width/2-10,
loaderView.frame.size.height/2-10);
spinner.hidesWhenStopped = YES;
}
[spinner startAnimating];
[self.window addSubview:loaderView];
[self.window bringSubviewToFront:spinner];
[self.window bringSubviewToFront:loaderView];
}
-(void)hideLoder
{
if (spinner!= NULL) {
[spinner stopAnimating];
}
[loaderView removeFromSuperview];
}
now import "AppDelegate.h" class where ever you want to call loader.and you can call the loader like this.
[app showLoader];
and
[app hideLoder];