无法为Label设置文本

时间:2013-06-03 21:55:53

标签: objective-c label protocols

在控制器中我有标签属性:

@interface BallsViewController : UIViewController <UIInteraction>
@property (weak, nonatomic) IBOutlet UILabel *ScoreLabel;

-(void)UpdateScore:(int)score;
@end

@interface BallsViewController ()
@end

@implementation BallsViewController
@synthesize ScoreLabel;
- (void)viewDidLoad
{
    [super viewDidLoad];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)UpdateScore:(int)score
{
    NSString *scoreStr =[NSString stringWithFormat:@"%d",score];
    [self.ScoreLabel setText:scoreStr];
    [self.InfoLabel setText:scoreStr];

}

@end

UpdateScore是协议方法。当我想将文本设置为ScoreLabel时,它有值:ScoreLabel UILabel * 0x00000000

这意味着它没有初始化?

当我设置文字时,在ui上它不会改变。

1 个答案:

答案 0 :(得分:0)

尝试将您的标签设置为强。

@property (strong, nonatomic) IBOutlet UILabel *ScoreLabel;