UILabel的奇怪问题

ahs*_*san 0 uilabel ios

我正在使用UILabel定制单元格UITableView.下面是我正在使用的所有代码:

头文件:

UILabel *timeLabels;
@property (nonatomic, retain) UILabel *timeLabels;
Run Code Online (Sandbox Code Playgroud)

代码文件:

- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier

    timeLabels=[[UILabel alloc] init];
    timeLabels.textAlignment=UITextAlignmentLeft;
    timeLabels.font=[UIFont boldSystemFontOfSize:12];
    timeLabels.backgroundColor=[UIColor clearColor];
    timeLabels.textColor=[UIColor blueColor];

- (void) layoutSubviews

   frame=CGRectMake(boundsX+5, 5, 60, 45);
   timeLabels.frame=frame;
Run Code Online (Sandbox Code Playgroud)
[timeLabels release]
Run Code Online (Sandbox Code Playgroud)

我收到以下错误 timeLabels.frame=frame;

2011-08-08 12:44:07.290 EncameoApp[2014:707] -[NSCFString setFrame:]: unrecognized selector sent to instance 0x136890
2011-08-08 12:44:07.361 EncameoApp[2014:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString setFrame:]: unrecognized selector sent to instance 0x136890'
Run Code Online (Sandbox Code Playgroud)

鉴于timeLabels不是NSString,而是UILabel,这很奇怪!

任何人都可以让我知道我错过了什么?谢谢.

Sun*_*iya 5

我也遇到过这种问题,但是我通过设置timeLabels的值解决了这个问题:

timeLabels.text = @"value";
Run Code Online (Sandbox Code Playgroud)

代替

timeLabels = @"value";
Run Code Online (Sandbox Code Playgroud)