2013-03-15 50 views
1

我有一个UIWebView的问题。如果一个iframe中加载一些内容出于某种原因,我改变源或我删除的元素,我得到以下异常:ios iframe问题与webview

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) 

是否有我需要添加到我的代码处理这种情况的东西?

回答

0

在我来说,那是因为我调用viewWillAppear中我的方法scrollToId,webWiew加载

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

之前应该在webViewDidFinishLoad

被调用