在StoryBoard中使用手势识别器时崩溃 [英] Crash when using gesture recognizers in StoryBoard

查看:118
本文介绍了在StoryBoard中使用手势识别器时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新

对于旧版本的Xcode来说,这是一个老问题。事实证明,问题是Xcode中的一个错误已修复。

This is an old question for an old version of Xcode. It turned out that the issue was a bug in Xcode which has been fixed.

原始

我有一个故事板来自制作新的标签iphone应用程序(使用ARC)

I have a storyboard generated from making a new tab iphone application (with ARC)

在我的一个标签中,如果我拖动手势识别器(任何,但是让我们说Pan)到一个控件上,然后将选择器设置为一个动作,它一旦我转到标签就会崩溃。

In one of my tabs, if I drag a gesture recognizer (any, but let's say Pan) onto a control, and then set the selector to an action, it just crashes as soon as I go to the tab.

没有任何内容控制台 - 在加载故事板时似乎正在发生(从未调用viewDidLoad)。

There is nothing in the Console -- it appears to be happening while the storyboard is being loaded (viewDidLoad is never called).


  1. 我无法弄清楚如何获取更多信息

  2. 在另一个标签页上,这样可以正常使用。这两个标签都是自动生成的。

(我可能在视图中搞砸了一些东西,但我没有一点线索来计算我做了什么)。

(it's possible I messed something up in the view, but I don't have a clue to figuring out what I did).

如果我以编程方式做手势,它们工作正常,但它很好用它在故事板中工作,我担心无论是什么错误会在某些时候以某种其他方式导致崩溃。

If I make gestures programmatically, they work fine, but it's nice to have it work in the storyboard, and I'm afraid that whatever is wrong will cause a crash some other way at some point.

更多信息

在模拟器中我得到

-[__NSCFString setView:]: unrecognized selector sent to instance 0x6d2db70

再次,需要调试技术 - 例如,有没有办法找出0x6d2db70是什么对象?

Again, need debugging techniques -- for example, is there a way to find out what object 0x6d2db70 is?

这与这个问题完全相同(没有答案):

Which is exactly like this question (with no answer):

界面生成器中的手势识别器崩溃了我的应用程序

MOR E INFO

重现这是微不足道的


  1. 新iPhone选项卡式应用程序,ARC和故事板

  2. 将点按手势拖到第二个标签的视图上(适用于第一个标签)

  3. 创建(IBAction)

  4. 将手势的选择器连接连接到#3

  5. 运行的操作,转到第二个选项卡

  1. New iPhone tabbed application, ARC and Storyboard on
  2. Drag tap gesture onto second tab's view (works on first one)
  3. Create an (IBAction)
  4. Connect the gesture's selector connection to the action from #3
  5. run, go to second tab

崩溃。与我的应用程序相同,默认选项卡有效,其他选项卡不工作

Crashes. Same thing with my app, default tab works, other tabs don't

推荐答案

错误消息告诉我们程序正在发送 setView:消息到 __ NSCFString 的实例(显然是的私有实现类NSString )。

The error message tells us that the program is sending the setView: message to an instance of __NSCFString (which is obviously the private implementation class of NSString).

确保您已尝试在启用僵尸的情况下运行。僵尸很容易导致无法识别的选择器错误。

Make sure you have tried running with zombies enabled. A zombie can easily cause an unrecognized selector error.

如果它不是僵尸,请在上设置一个断点 - [NSObject doesNotRecognizeSelector:] 。当断点被击中时,您可能只能从堆栈跟踪中找出问题。如果没有,您可以打印对象的 debugDescription (对于大多数类,它与描述相同)。

If it's not a zombie, put a breakpoint on -[NSObject doesNotRecognizeSelector:]. When the breakpoint is hit, you may be able to figure out the problem just from the stack trace. If not, you can print the debugDescription of the object (which is the same as the description for most classes).

在模拟器上,您可以要求调试器打印对象的 debugDescription ,如下所示:

On the simulator, you can ask the debugger to print the object's debugDescription like this:

(gdb) frame 0
#0  0x013bcbff in -[NSObject doesNotRecognizeSelector:] ()
(gdb) po ((int*)$ebp)[2]
this is my test string

在设备上,你这样做:

(gdb) frame 0
#0  0x344bca22 in -[NSObject doesNotRecognizeSelector:] ()
(gdb) po $r0
this is my test string



更新



根据您的重现步骤,这是UIKit中的一个错误。 提交错误报告。您可以通过在 SecondViewController 并将其连接到手势识别器。 确保在 viewDidUnload 中将插座设置为nil。

Update

Based on your steps to reproduce, this is a bug in UIKit. File a bug report. You can work around the bug by creating a strong outlet on SecondViewController and connecting it to the gesture recognizer. Make sure you set the outlet to nil in viewDidUnload.

不要将你的插座设置为零 - 部分错误是UIKit没有保留 - 你需要保留你的参考以确保识别器不是发布。

Do not ever set your outlet to nil -- part of the bug is that UIKit isn't retaining -- you need to keep your reference to make sure that the recognizers aren't released.

这篇关于在StoryBoard中使用手势识别器时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆