2013-05-21 47 views
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? 

異常消息:IOS的​​UILabel SETFRAME錯誤

-[__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中的.xib,UseAutoLayout,IOS SDK 6.1

+0

顯示你已經聲明瞭'forwardView','height'和'rootViewHeight'的代碼... ... – rog

+0

float height = [self calcNewsContentHeight:text WithWidth:288.0f]; float rootViewHeight = [self calcNewsContentHeight:text1 WithWidth:288.0f]; @property(弱,非原子)IBOutlet UIView * forwardView; – vict

+0

crash [self.tvContent setFrame:frame]; – vict

回答

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 

該系統給你的類的對象,你想發送的消息 - 在這種情況下,您嘗試撥打setFrame:的NSString。

此信息加上您知道哪條線路崩潰可以得出一個簡單的結論:self.tvContentNSString,您可能期望得到一個UILabel

+0

@property(弱,非原子)IBOutlet UILabel * tvContent; tvContent是UILabel,在.h中 – vict

+0

@user在應用程序運行期間的某個時刻,您將該屬性設置爲等於'UILabel'。 – Undo

+1

謝謝,stupit錯誤,self.tvContent = [rowData objectForKey:@「News」]; – vict

1
-[__NSCFString setFrame:] 

您的應用程序認爲tvContent是一個字符串,而不是一個視圖。確保您的插座正確連接到您的用戶界面。另外,如果你有一個tvContent的屬性,它必須是一個擁有的引用(例如強(ARC)或保留(非ARC))。

+0

@property(弱,非原子)IBOutlet UILabel * tvContent; tvContent是UILabel,在.h – vict

+0

項目中使用ARC。 – vict

+0

把它從弱變強,如果一切順利的話,它應該可以工作。 – BergQuester