【发布时间】:2015-12-09 11:59:04
【问题描述】:
有时我的应用程序运行良好,但有时会失败并出现以下错误:
* WebKit 在 webView 中丢弃了一个未捕获的异常:didFinishLoadForFrame: delegate: * -[__NSArrayM objectAtIndex:]: index 6 beyond bounds [0 .. 5]
我发现了一些关于 WebKit 中异常的其他问题,但没有一个与 NSRangeException 相关的问题。
我的代码:
- (id) init {
myWebView = [[UIWebView alloc] init];
myWebView.delegate = self;
[myWebView stopLoading];
return self;
}
- (void)loadUrl:(NSString *)urlAddress {
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[myWebView stopLoading];
[myWebView loadRequest:requestObj];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
if (!myWebView.isLoading) {
[myWebView stopLoading];
if (selectedInfo == LOADTable) {
NSString *html = [NSString stringWithFormat:@"%@",[myWebView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML"]];
[myWebView stopLoading];
[self parseTable:html];
}
}
}
有没有人知道如何解决这个错误。
UIWebView 未显示在任何UIView 上。仅用于加载 HTML。
【问题讨论】:
-
请使用异常断点为您的崩溃找到确切的链接,另一个帮助是:请为您的 UIWebView 使用强引用,最后请不要在 init 方法中调用停止加载
-
@MohamadFarhand:感谢
Exception breakpoint的提示。解决它以找到确切的错误。
标签: ios objective-c webview uiwebview webkit