开发者

Implementing activity indicator

I am implementing an activity indicator in my application. In my application on button clic开发者_运维问答k a webservice is called and it takes some time. To show the user that process is going on I implemented an activity indicator:

CGRect frame = CGRectMake(140, 300, 40, 37); 
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:frame];
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 
[self.view  addSubview:activityIndicator];

This Snippet is written in viewDidLoad() method, and I have an action called,

-(IBAction)agree:(id)sender
{ 
 //here webservice is called
}

I have to start that activity by [activityIndicator startAnimating];

But I am unable to start that activityIndicator, please suggest a proper solution for that.


Put this code into your web view.

 -(void) viewDidLoad
{ 
   activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

  activityIndicator.frame = CGRectMake(0.0, 0.0, 20.0, 20.0);

   activityIndicator.center=self.view.center;

  [activityIndicator startAnimating];

  [self.view addSubview:activityIndicator];
 }

  - (void)webViewDidStartLoad:(UIWebView *)webView
   {

       [activityIndicator startAnimating];

  }

 - (void)webViewDidFinishLoad:(UIWebView *)webView
 {

   [activityIndicator stopAnimating];

  }

Refer this link link text. This explains to display the activity indicator for parsing action of the rss feed

Best of Luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜