2013-06-03 52 views
0

在控制器设置文本我有标签属性:无法为标签

@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上它不会改变。

+0

在您的笔尖或故事板视图上,您​​是否将标签连接到了ScoreLabel?你是否确定UpdateScore被调用? – MichelleJS

+0

是的,我连接它。 UpdateScore总是被调用。 – netmajor

+0

如果您在'UpdateScore:'方法中使用'NSLog(@“%@”,self.ScoreLabel)'',您会得到什么? –

回答

0

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

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