activityIndicatorを実行して、設定したCGRectフレームにwebViewを正しくロードしようとしています。
セットアップすると正しくロードされます[self.view addSubview:webView];
が、アクティビティインジケータは表示されません。activityindicatorを設定するとwebView.delegate = self;
表示されますが、ロード時に webview が画面全体を覆います。上部にセグメント化されたバーがあり、それが覆われています。
- (void)viewDidLoad {
[super viewDidLoad];
CGRect webFrame = CGRectMake(0.0, 50.0, 320.0, 318.0);
activityIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[self.view addSubview:activityIndicator];
activityIndicator.frame = CGRectMake(250, 250, 30.0, 30.0);
self.view.center = CGPointMake(160.0f, 190.0f);
activityIndicator.center = self.view.center;
webView = [[UIWebView alloc] initWithFrame:webFrame];
[webView setBackgroundColor:[UIColor whiteColor]];
NSString *urlAddress = @"http://www.google.com";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
webView.delegate = self;
// [self.view addSubview:webView];
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
NSLog(@"activity started");
[activityIndicator startAnimating];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
NSLog(@"activity stopped");
[activityIndicator stopAnimating];
self.view = webView;
}