1

I have an iPad application when view is loaded, i am calling method after some time duration so i want to display a loading bar till method is called and data is loaded.

I am Using NSTimer to call a method in viewDidLoad

[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(loadNews) userInfo:nil repeats:NO];
NeverHopeless
  • 11,077
  • 4
  • 35
  • 56
Ali
  • 1,951
  • 2
  • 14
  • 14
  • 1
    http://stackoverflow.com/questions/1397426/iphone-splash-screen-with-progress-bar – ram Jul 30 '11 at 07:06
  • i think loading bar or progress bar would not look good for iPhone.. for alternative use Activity indicator... please see answer below – DShah Jul 30 '11 at 07:31

4 Answers4

2

Use Activity Indicator to show progress bar or loading view.... like below.... in viewdidload..

CGRect frame = CGRectMake(0.0, 0.0, 25.0, 25.0);
    self.activityIndicator = [[UIActivityIndicatorView alloc]
                              initWithFrame:frame];
    [self.activityIndicator sizeToFit];
    self.activityIndicator.autoresizingMask =
    (UIViewAutoresizingFlexibleLeftMargin |
     UIViewAutoresizingFlexibleRightMargin |
     UIViewAutoresizingFlexibleTopMargin |
     UIViewAutoresizingFlexibleBottomMargin);
    [activityIndicator startAnimating];

    UIBarButtonItem *loadingView = [[UIBarButtonItem alloc] 
                                    initWithCustomView:self.activityIndicator];
    loadingView.target = self;
    self.navigationItem.rightBarButtonItem = loadingView;
DShah
  • 9,768
  • 11
  • 71
  • 127
1

You can use a UIProgressView to display loading progress. The Mail app uses this when downloading messages. For indefinite time periods, use a UIActivityIndicatorView instead.

enter image description here

It's discussed in the iOS HIG.

progrmr
  • 75,956
  • 16
  • 112
  • 147
0

Rather Do

[NSThread detachNewThreadSelector:@selector(loadNews) toTarget:self withObject:nil];

Then stop the loadingview when you are finished using something like

[activityIndicator setHidden:YES];

Hope this helps you.

Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
  • no its now working i want that as we open page in safai it shows cirle moving untill page is load like i want – Ali Jul 30 '11 at 07:10
0

I like to use MBProgressHUD. It lets you easily customize your loading progression, with different states. Like initialization, downloading, cleaning...

Cyprian
  • 9,423
  • 4
  • 39
  • 73