[UILabel copyWithZone:]:无法识别的选择器发送到实例 [英] [UILabel copyWithZone:]: unrecognized selector sent to instance

查看:107
本文介绍了[UILabel copyWithZone:]:无法识别的选择器发送到实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得我在这里碰到了我的头(我坦白地准备这样做了。)

I feel like I'm banging my head against the wall here (and I'm ready to do that, frankly).

我正试图设置视图的背景。我需要设置的背景是一个图像,我正在使用这个代码(在其他两个UIViewController子类中完全正常 - 这是复制/粘贴到新文件中):

I'm trying to set a background to the view. Background I need to set is an image and I'm using this code (which works perfectly fine in two other UIViewController subclasses - this was a copy/paste into the new file):

UIImage *img = [gameNode imageFromKey:@"background"];
UIColor *bg = [[UIColor alloc] initWithPatternImage:img];
self.view.backgroundColor = bg;
[bg release];

正如我所说,这在其他两个地方完美无缺,不过在这里,行 self.view.backgroundColor = bg throws

As I said, this works perfectly fine in two other places, however here, line self.view.backgroundColor = bg throws

'NSInvalidArgumentException', reason: '-[UILabel copyWithZone:]: unrecognized selector sent to instance 0x9259840'

没有更多可去的。我在IB中验证了顶级视图的引用插座设置为文件的所有者。我清理了项目并重新启动。我甚至关闭了Xcode并重新启动它 - 没有运气。我还缺少什么呢?

There's not much more to go by. I verified in IB that the top-level view's referencing outlet is set to the File's owner. I cleaned the project and restarted. I even closed Xcode and restarted it again - no luck. What else am I missing?

编辑:正如我所提到的,后备堆栈跟踪不多,只有这样:

As I mentioned, there's not much back stack trace, just this:

2012-05-28 13:13:56.997 OOKL[36012:17303] -[UILabel copyWithZone:]: unrecognized selector sent to instance 0x92b79a0
2012-05-28 13:13:56.997 OOKL[36012:17303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILabel copyWithZone:]: unrecognized selector sent to instance 0x92b79a0'
*** First throw call stack:
(0x2933052 0x44c7d0a 0x2934ced 0x2899f00 0x2899ce2 0x2935bd9 0xaa92dd 0x6a4f40 0x6a4eeb 0x6bfd60 0xc0191a 0x2934e1a 0x289e821 0xc0046e 0xaa7e2c 0xaa83a9 0xaa85cb 0xb2b59 0xb1969 0x2934ec9 0x9e55c2 0x9e555a 0xa8ab76 0xa8b03f 0xa8a2fe 0xa0aa30 0xa0ac56 0x9f1384 0x9e4aa9 0x2ac6fa9 0x29071c5 0x286c022 0x286a90a 0x2869db4 0x2869ccb 0x2ac5879 0x2ac593e 0x9e2a9b 0x214d 0x20c5)

没有别的 - 在之前或之后。

Nothing else - before or after.

推荐答案

我想这是Xcode的一个奇怪的错误,你不能每次都追踪或重现。我将问题缩小到IB中的一个特定UILabel。一旦我将它连接到 IBOutlet UILabel * ,我就会收到此错误。

I guess this was one of those weird bugs with Xcode that you can't trace or reproduce every time. I narrowed the issue down to one specific UILabel in the IB. As soon as I connect it to an IBOutlet UILabel *, I get this error.

在进一步调查中,它事实证明,名称 title 导致了这个问题。我将标签声明为

On further investigation, it turns out that name title was causing the issue. I had the label declared as

IBOutlet UILabel *title;

我将名称更改为 gtitle ,一切都按预期工作。谁知道?..

As soon as I changed the name to gtitle, everything worked as expected. Who knows?..

这篇关于[UILabel copyWithZone:]:无法识别的选择器发送到实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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