你可以像這樣文件
@interface SecondViewController
{
UIActivityIndicatorView *activityView;
}
@property (nonatomic, retain) UIActivityIndicatorView *activityView;
@end
在.m文件
@synthesize activityView;
- (void) viewDidLoad
{
self.activityView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 80, 30, 30)];
self.activityView.hidesWhenStopped = YES ;
[self addSubview:activityView];
activityView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[activityView startAnimating];
[self performSelector:@selector(getData) withObject:nil afterDelay:0.1];
}
- (void) getData
{
// code for server call
.
.
// as downloading get complited
[self.activityView stopAnimating]
}