2013-06-03 31 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;