I cannot display Indicator View.
ItemController.h
#import <UIKit/UIKit.h>
@interface ItemController : UITableViewController {
UIView* loadingView;
UIActivityIndicatorView* indicator;
}
@property (nonatomic, retain) UIView *loadingView;
@property (nonatomic, retain) UIActivityIndicatorView *indicator;
@end
ItemController.m
.....
- (void)netAccessStart {
loadingView = [[UIView alloc] initWithFrame:[[self view] bounds]];
[loadingView setBackgroundColor:[UIColor blackColor]];
[loadingView setAlpha:0.5];
indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[[self view] addSubview:loadingView];
[loadingView addSubview:indicator];
[indicator setFrame:CGRectMake ((320/2)-20, (480/2)-60, 40, 40)];
[indicator startAnimating];
}
- (void)netAccessEnd {
[indicator stopAnimating];
[loadingView removeFromSuperview];
}
- (void)dealloc {
[loadingView release];
[indicator release];
[super dealloc];
}
.....
inherited class
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self netAccessStart];
sleep(1);
[self netAccessEnd];
}