UIActivityIndicatorView를 좀 써서 페이지 여는 동안 가운데 에서 동글 동글 돌리려면
UIWebViewDelegate 프로토콜 메서드 두개를 구현해주고
UIActivityIndicatorView를 start/ stop 해주면 된다.
헤더 파일
#import <UIKit/UIKit.h>
@interface WebViewController : UIViewController <UIWebViewDelegate> {
UIActivityIndicatorView *webActInd;
}
@end
m파일
- (void)viewDidLoad
{
[super viewDidLoad];
//Web URL View
UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 45, 320, 415)];
[webView setDelegate:self];
NSString *url = @"http://mtsparrow.blogspot.kr";
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
[self.view addSubview:webView];
[webView release];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// 액티비티인디케이터 설정
webActInd = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[webActInd setFrame:CGRectMake(0.0, 0.0, 50.0, 50.0)];
[webActInd setCenter:CGPointMake(320/2, 480/2)];
[self.view addSubview:webActInd];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// Do any additional setup after loading the view.
webActInd = nil;
}
- (void)dealloc
{
[super dealloc];
[webActInd release];
}
// 뷰를 부르기 시작
- (void)webViewDidStartLoad:(UIWebView *)webView {
[webActInd startAnimating];
}
// 뷰가 화면에 표시
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[webActInd stopAnimating];
}
댓글 없음:
댓글 쓰기