1
#import <QuartzCore/QuartzCore.h>
- (void)viewDidLoad
{
    [self.forwardView setFrame:CGRectMake(12.0, 40.0+height, 296.0, rootViewHeight-15.0)];

    self.forwardView.layer.borderColor = [UIColor colorWithRed:153.0/250.0 green:153.0/250.0 blue:153.0/250.0 alpha:100].CGColor;
    self.forwardView.layer.borderWidth = 1;
    CGRect frame = CGRectMake(12.0f, 40.0f, 288.0f , height);
    [self.tvContent setFrame:frame];
}


[self.tvContent setFrame:frame]; //crash?

异常消息:

-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x7894c00
2013-05-21 10:44:54.677 Sohappy[22295:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x7894c00'
*** First throw call stack:
(0x1eb5012 0x19aae7e 0x1f404bd 0x1ea4bbc 0x1ea494e 0xfb407 0xfc20b 0x9d01c7 0x9d0232 0x9d04da 0x9e78e5 0x9e79cb 0x9e7c76 0x9e7d71 0x9e889b 0x9e8e93 0x8ef13f7 0x9e8a88 0x93b9 0x99df83 0x99e4ed 0x13a85b3 0x1e74376 0x1e73e06 0x1e5ba82 0x1e5af44 0x1e5ae1b 0x24e27e3 0x24e2668 0x8eeffc 0x2acd 0x29f5 0x1)
libc++abi.dylib: terminate called throwing an exception

UILabel in .xib , UseAutoLayout, ios sdk 6.1

4

2 回答 2

6

您正在尝试设置一个NSString不存在的东西的框架。self.tvContent是一个 NSString,而不是你似乎怀疑的 UILabel。


这是学习如何阅读异常的好机会。我在这里为你分解:

-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x7894c00
2013-05-21 10:44:54.677 Sohappy[22295:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x7894c00'
*** First throw call stack:
(0x1eb5012 0x19aae7e 0x1f404bd 0x1ea4bbc 0x1ea494e 0xfb407 0xfc20b 0x9d01c7 0x9d0232 0x9d04da 0x9e78e5 0x9e79cb 0x9e7c76 0x9e7d71 0x9e889b 0x9e8e93 0x8ef13f7 0x9e8a88 0x93b9 0x99df83 0x99e4ed 0x13a85b3 0x1e74376 0x1e73e06 0x1e5ba82 0x1e5af44 0x1e5ae1b 0x24e27e3 0x24e2668 0x8eeffc 0x2acd 0x29f5 0x1)
libc++abi.dylib: terminate called throwing an exception

以下是您感兴趣的内容:

-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x7894c00

系统为您提供对象的类和您尝试发送的消息 - 在本例中是您尝试调用的 NSString setFrame:

这些信息再加上您知道哪条线路正在崩溃,可以得出一个简单的结论:self.tvContentNSString可能期望UILabel.

于 2013-05-21T03:23:37.980 回答
1
-[__NSCFString setFrame:]

您的应用认为 tvContent 是一个字符串,而不是一个视图。确保您的插座正确连接到您的 UI。此外,如果您有 tvContent 的属性,它必须是拥有引用(例如 strong(在 ARC 下)或 retain(非 ARC))。

于 2013-05-21T03:20:53.173 回答