2010-01-21 2 views
2

Webview에서 원격 URL을로드하고 있으며 컨텐츠가로드되는 동안 회 전자를 표시하려고합니다. 다음 코드는 있지만 콘텐츠로드가 끝나면 회 전자가 사라지지 않습니다. 콘텐츠가로드 된 후 회 전자가 사라지도록하려면 어떻게해야합니까?Webview Xcode의 회 전자로드

NSURL *noteURL = [NSURL URLWithString:@"http://google.com/"]; 
NSString *defaultNote = @"Hello there"; 

NSRect frame = [[noteView superview] frame]; 
noteSpinner = [[[NSProgressIndicator alloc] initWithFrame:NSMakeRect(NSMidX(frame)-16, NSMidY(frame)-16, 32, 32)] autorelease]; 
[noteSpinner setStyle:NSProgressIndicatorSpinningStyle]; 
[noteSpinner startAnimation:self]; 
//webViewFinishedLoading = NO; 
[[noteView superview] addSubview:noteSpinner]; 

if (noteURL) 
{ 
    if ([noteURL isFileURL]) 
    { 
     [[noteView mainFrame] loadHTMLString:@"Release notes with file:// URLs are not supported for security reasons—Javascript would be able to read files on your file system." baseURL:nil]; 
    } 
    else 
    { 
     [[noteView mainFrame] loadRequest:[NSURLRequest requestWithURL:noteURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]]; 
    } 
} 
else 
{ 
    [[noteView mainFrame] loadHTMLString:defaultNote baseURL:nil]; 
} 

답변

2

Be the frame load delegatestop the progress indicator's animation 메인 프레임로드 종료한다.

did-finish-load 메시지를받은 프레임이 웹보기의 주 프레임 인 경우에만 애니메이션을 중지하십시오. 중첩 된 프레임과 iframe을 포함하여 웹보기의 모든 프레임에 대해 해당 메시지 중 하나를받습니다. 애니메이션을 조기에 중단하고 싶지는 않습니다.

+0

메인 프레임로드가 언제 완료되는지 어떻게 알 수 있습니까? – Chetan

+0

무슨 뜻입니까? 'stopAnimation' 명령은 어디에 두어야합니까? – Chetan

+1

신경 쓰지 마라. 기록을 위해, 동일한 클래스에 다음 함수를 정의 할 필요 - (무효) 웹보기 (웹뷰 *) 발신자 didFinishLoadForFrame : 프레임 { \t 경우 ([프레임 parentFrame] == 닐) { \t \t [noteSpinner setHidden : YES]; \t \t [발신자 표시]; } } – Chetan