添加视图时崩溃 (SIGABRT)。 (网页视图)
我在添加 WebView 时发生崩溃(由异常触发)。我还没弄清楚为什么。是的,我浏览过网页,因为这是一个非常常见的问题,尽管没有成功,我找到了一个答案,说我应该实现 DSYM 来正确跟踪堆栈,因为查看所有这些地址是毫无意义的(我同意) ,问题是我不知道如何做到这一点。我发现了这个:保存 dsym 文件。但我不知道如何将它集成到我的项目中,而且它看起来很危险。是的,我也启用了 NSZombie,但没有效果。
不管怎样,现在说到我的问题了。我有一个触发事件的按钮,该事件根据按下的按钮更改字符串(URL)。然后,此 IBAction 调用委托,委托将转换到具有 UIWebView 的视图,该视图将使用 IBAction 编辑的 URL 打开。所以我有以下代码:
这是委托方法:
WebViewController *awebViewController = [[WebViewController alloc]
initWithNibName:@"WebView" bundle:nil];
[self setWebViewController:awebViewController];
[awebViewController release];
self.webViewController.finalURL = [NSMutableString stringWithFormat:@"%@", linkString];
[viewController.view removeFromSuperview];
// HERE happens the crash, found out using breakpoints
[self.window addSubview:[webViewController view]];
[UIView commitAnimations];
[viewController release];
viewController = nil;
这是确切的崩溃消息:
-[WebView initWithCoder:]: unrecognized selector sent to instance 0x5718320
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '[WebView initWithCoder:]: unrecognized selector sent to instance 0x5718320'
我的理论是它尝试进行转换,但没有实际的视图可以添加。尽管这是一个疯狂的猜测。异常通常是由这类事情调用的,但在这种情况下我看不到发生了什么。
感谢您的帮助,如果问题太愚蠢,请原谅我。
I am having a crash (triggered by an exception) while adding a WebView. I haven't figured out why. And yes I have browsed the web because this is a very common problem though with no success, I found an answer saying that I should implement the DSYM to track the stack correctly, because looking at all those addresses is just meaningless (and I agree), the thing is I have no idea on how to do this. I found this: save dsym files. But I didn't figure out how to integrate it into my project, besides it looks dangerous. And yes I have NSZombie enabled too, but to no avail.
Anyway now to the point of my question. I have a button that triggers an event, the event changes a string (the URL) according to the button pressed. Then this IBAction calls on the delegate, and the delegate makes a transition to a view that has a UIWebView that will open with the URL edited by the IBAction. So I have the following code:
This is the Delegate method:
WebViewController *awebViewController = [[WebViewController alloc]
initWithNibName:@"WebView" bundle:nil];
[self setWebViewController:awebViewController];
[awebViewController release];
self.webViewController.finalURL = [NSMutableString stringWithFormat:@"%@", linkString];
[viewController.view removeFromSuperview];
// HERE happens the crash, found out using breakpoints
[self.window addSubview:[webViewController view]];
[UIView commitAnimations];
[viewController release];
viewController = nil;
This is the exact crash message:
-[WebView initWithCoder:]: unrecognized selector sent to instance 0x5718320
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '[WebView initWithCoder:]: unrecognized selector sent to instance 0x5718320'
I have the theory that it tries to make the transition but that there is no actual view to add. Though that is a wild guess. Exceptions are usually called by those kinds of things but in this case I don't see what is happening.
Thank you for your help, and forgive me if it is too dumb a question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的猜测是:
您的笔尖中是否有一个应该是 UIWebView 的视图,但您将该视图的类更改为 WebView?
您应该首先在界面生成器中检查这一点。
如果将视图元素的类更改为不可用的类,就会发生此异常。
a guess from my side:
Do you have a view in your nib that should be a UIWebView but you changed the Class of that view to WebView?
You should first check this in interface builder.
This exception is exactly what happens if you change the Class of a view element to a class that isn't available.
确切的错误是内存地址
0x5718320
处名为WebView
的类(不是UIWebView
)的某个实例正在被调用发送了消息-initWithCoder:
,但它无法识别该消息。当加载使用 Interface Builder 创建的视图时,会调用该消息;检查您的笔尖是否有已更改为自定义WebView
类的视图。The exact error is that some instance of a class called
WebView
(notUIWebView
) at memory address0x5718320
is being sent the message-initWithCoder:
, which it doesn’t recognize. That message is called when loading views created with Interface Builder; check your nibs for a view that you’ve changed to a customWebView
class.我遇到了同样的问题,并通过 XCode refractor/Rename 功能将 WebView 类重命名为 WebViewCustom,清理了项目,现在它工作正常。
I had same problem, and renamed class WebView into WebViewCustom by XCode refractor/Rename feature, cleaned up project and now it works fine.