UIWebView & NavigationController crashes while loading

跟風遠走 提交于 2019-12-25 04:01:33

问题


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:


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.



来源:https://stackoverflow.com/questions/12611913/uiwebview-navigationcontroller-crashes-while-loading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!