1

I have a UIWebView which will load the documents. All the supported documents mentioned for webview it is working. But sometimes , the UIWebView is getting crashed whenever I move back and forth quickly. I mean I am clicking back and opening file again and again. If I do so , my app is getting crashed.

Any idea why this is happening ?? It is working cool for video,audio and txt files, but weird crashing for the Office docs and numbers,pages documents.

Please help me out !!

-(void) backBtnPressed
{
    [_webView stopLoading];
    if ([_webView superview])
    {      
        [_webView removeFromSuperview];
        self.navigationItem.rightBarButtonItem = nil;
    }
}

- (void) loadFile:(NSString*)filePath
{
    NSURL*  url = [NSURL fileURLWithPath:filePath];
    NSURLRequest*   request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
    [webView setScalesPageToFit:YES];
}
4

7 に答える 7

0

これを実装して、発生しているエラーを確認してください。

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
    {
       NSLog("Error=%s",error);
    }
于 2012-06-13T11:04:05.080 に答える
0

コントローラのdeallocでWebビューのデリゲートプロパティをnilに設定します

于 2012-06-13T10:03:23.073 に答える
0

If you are moving from one view controller to another, do the following

[webView stopLoading];
webView.delegate = nil;
于 2012-06-13T10:07:27.607 に答える
0

The problem is solved.Setting the UIWebView to nil and loading the request again in the WebView. But now only at most worst case the App is getting crashed.

于 2012-07-11T05:08:44.007 に答える
0

Try this :

-(void)viewWillDisappear:(BOOL)animated
    {
        if([webView isLoading])
        {
            [webView stopLoading];
        }
    }
于 2012-07-11T05:18:17.760 に答える
0

Just adding this here on the off chance that someone else is making the same beginner mistake:

Remember that webView.delegate is a weak reference. If you set it to something else than self your delegate may get destroyed if there are no other references to it, which will cause all kinds of crashes.

于 2015-11-04T07:06:08.600 に答える
-1

Try to do the following. It works for me.

[webView stopLoading];
[webView release];
webView = nil;
webView.delegate = nil;
于 2012-11-01T06:11:48.523 に答える