본문 바로가기

프로그래밍/iphone

Loading중 alert창에 indicator 표시하기

먼저 delegate.h 에 선언 
 @interface testAppDelegate: NSObject
UIWindow *window; 
UITextField *textfield; 
UIWebView *webView; 
UIActivityIndicatorView *indicator; 
UIAlertView *alert; 
}
 이후 property, synthesize 를 각각 선언한다. 
-(void)webViewDidStartLoad:(UIWebView *)webView 에 시작코드를 -(void)webViewDidFinishLoad:(UIWebView *)webView 에 해제코드를 삽입한다. 
 






------------------------- - 

-(void)webViewDidFinishLoad:(UIWebView *)webView { 
 statusLabel.text = @"finished";
 [alert dismissWithClickedButtonIndex:0 animated:YES]; 
 - (void)webViewDidStartLoad:(UIWebView *)webView {
 statusLabel.text = @"start";
 alert =[[[UIAlertView alloc] initWithTitle:@"잠시만 기다려주세요.\n로딩중..." 
 message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:nil] autorelease];
 [alert show]; 

indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
 indicator.center = CGPointMake(alert.bounds.size.width/2, alert.bounds.size.height-50); [indicator startAnimating]; 
 
[alert addSubview:indicator];
 [indicator release];
 }