ios iframe与webview有关

时间:2013-03-15 19:06:05

标签: ios iframe webview

我有UIWebView的问题。如果iframe正在加载某些内容,并且由于某种原因我更改了源代码或删除了该元素,则会出现以下异常:

MyApp[5812:11303] shouldStartLoadWithRequest
2013-03-14 18:48:45.899 MyApp[5812:11303] shouldStartLoadWithRequest
2013-03-14 18:48:45.900 MyApp[5812:11303] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> *** setObjectForKey: key cannot be nil
2013-03-14 18:48:45.901 MyApp[5812:13603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'
*** First throw call stack:
(0x1c94012 0x10d1e7e 0x1d170de 0x26e35ce 0x26e5693 0x26d44b5 0x2bf8747 0x2bf5610 0x2ec841a 0x2ec6c49 0xb0108ef 0x6619e11 0x6572fc3 0x2dd9d34 0x2eacd15 0x2b31eac 0x2b31c76 0x317bce9 0x2b176d5 0x2b184a5 0x316ade9 0x2b1772e 0x317cc6d 0x2b1e3f4 0x2b1f97b 0x2b2382f 0x26f1f7b 0x356182c 0x3561795 0x3564b2f 0x35648bb 0x356bffb 0x356487c 0x1e50f4 0x356bffb 0x1e4deb 0x1e5787 0x356c548 0x1c17f3f 0x1c17a39 0x1c3a734 0x1c39f44 0x1c39e1b 0x356bc50 0x97efced9 0x97f006de)
libc++abi.dylib: terminate called throwing an exception
(lldb)

我需要在代码中添加与此方案相关的内容吗?

1 个答案:

答案 0 :(得分:0)

在我的情况下,这是因为我在viewWillAppear中调用我的方法scrollToId,然后才加载webWiew

- (void)scrolToID
{
    NSString *jsCall = [NSString stringWithFormat:@"window.location.hash='#%@'", currentID];
   [self.webView stringByEvaluatingJavaScriptFromString:jsCall];
}

应该在webViewDidFinishLoad中调用