[_UIWebViewScrollViewDelegateForwarder scrollViewWasRemoved:]:无法识别的选择器发送到实例

时间:2014-06-06 13:59:07

标签: ios objective-c ipad uiwebview uiscrollview

我有一个非常奇怪的错误,我找不到问题。

在我的iPad APP中,我有一个UINavigationController,一个UITableViewController作为主人,一个UIViewController包含一个UIWebView作为细节。

我启动了APP,显示了UITableViewController。通过segue我像往常一样打开细节。然后我在detailviewcontroller中有一个调用此方法的后退按钮

[self.contentWebView setDelegate:nil];
[self.contentWebView stopLoading];
[self.navigationController popViewControllerAnimated:YES];

它被加速,主人再次出现。它的

- (void)viewWillAppear:(BOOL)animated

被调用,但后来我收到以下错误:

2014-06-06 15:56:58.156 Knowledge[356:60b] -[_UIWebViewScrollViewDelegateForwarder scrollViewWasRemoved:]: unrecognized selector sent to instance 0x170429f60
2014-06-06 15:56:58.159 Knowledge[356:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UIWebViewScrollViewDelegateForwarder scrollViewWasRemoved:]: unrecognized selector sent to instance 0x170429f60'
*** First throw call stack:
(0x189582f50 [...] 0x196553aa0)
libc++abi.dylib: terminating with uncaught exception of type NSException

但是,这只发生在iPad Air上......旧的iPad按预期工作

更新: 我现在在“stopLoading”之后添加了命令 [self.contentWebView removeFromSuperview]; ,现在错误就在那里。

1 个答案:

答案 0 :(得分:0)

如果您没有触及滚动视图(网络视图)委托参考,请忽略此答案

我面临同样的奇怪错误。经过一些调查后,我发现它发生了,因为滚动视图(Web视图)委托在控制器的viewDidLoad方法中被更改了:

[self webView].scrollView.delegate = self;

在某些情况下,即使在视图控制器被销毁之后,滚动视图也会调用委托方法。这应该通过weak委托引用来防止,但由于某种原因,滚动视图无论如何都会调用deallocated(zombie)对象上的委托方法。我认为这是框架中的一个错误。

所以,您可以执行以下操作:在控制器的nil方法中将委托引用设置为dealloc

- (void)dealloc
{
    [self webView].scrollView.delegate = nil;
}

取消分配后,将阻止滚动视图在不再存在的控制器上调用任何方法。