UIWebView & NavigationController crashes while loa

2019-09-13 08:05发布

I have very weird problem

I build a simple app with UIWebView and NavigationController but the problem is when the seconds page is loading and I go back to the first page and visited a link the APP crashes and the console says nothing

Here is my code on finish loading

-(void)webViewDidFinishLoad:(UIWebView *)aWebView {
    NSString *str = [aWebView stringByEvaluatingJavaScriptFromString:@"document.title"];
    self.navigationItem.title = str; 
     [navigationActivity stopAnimating];
}

and this for the web view should start loading

if(navigationType == UIWebViewNavigationTypeOther)
    {
        NSURL *url2 = [request URL];
        NSString *URLStr = [url2 absoluteString];

        RootViewController* viewController = [[RootViewController alloc] init];
        NSString *holder = [self getQueryStringInner:URLStr];
        [self getQueryString:URLStr];
        if([holder length] != 0 && [flag length] != 0 && !facebook )
        {

            appDelegate.title =@"Title"; 
            appDelegate.query = queryString;
            appDelegate.url = holder; 

            [self.navigationController pushViewController:viewController animated:YES];
            [viewController release];
            return NO;
        }
}

I am really new to Objective-c and iOS development so any help will be appreciated

Any Help

1条回答
迷人小祖宗
2楼-- · 2019-09-13 08:48

Seems that the necessary step is to call [webView stopLoading] in your viewWillDisappear. Apparently the web view delegate was sending the webViewDidFinishLoading method message to a deallocated instance. Glad you got it worked out.

查看更多
登录 后发表回答