开发者

problem with adding UIActivityIndicator to the view !

I am trying to add a UIActivityIndicator to my custom view (programmatically). I am using the following code. But I dont see anything on the screen. Any idea why ?

Thanks.

UIActivityIndicatorView *activityIndicator=[[[UIActivityIndicator开发者_如何学GoView alloc] initWithFrame:CGRectMake(75, 395, 200, 200)] autorelease];
[activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityIndicator.center=self.view.center;
[self.view addSubview:activityIndicator];


UIActivityIndicator has its hidesWhenStopped property equal to YES by default - that is it is hidden if you do not start animating it. So to make it appear on the screen try one of the following (whichever is more suitable for you):

  1. set hidesWhenStopped property to NO
  2. start animating it (using -startAnimating method)
  3. comment "activityIndicator.center=self.view.center;"


Another reason is maybe because you're not set the activity indicator position correctly. From what I see, you want to place the activity indicator to the center of it's parent view. But to do that, you must do something like activityIndicator.center = CGPointMake(self.view.frame.origin.x + self.view.bounds.size.width / 2.0, self.view.frame.origin.y + self.view.bounds.size.height / 2.0);

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜