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):
- set
hidesWhenStopped
property toNO
- start animating it (using
-startAnimating
method) - 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);
精彩评论