@interface TopBarController : UIViewController <AVAudioPlayerDelegate, UIAlertViewDelegate> {
UILabel *coinWatch; }
@property (nonatomic,retain) UILabel *coinWatch;
- (UIView *)coinsLabel {
UIView *coinsLabelView=[[UIView alloc]initWithFrame:CGRectMake(36, 17, 100, 15)];
//if (coinsLabelView == nil) {
coinWatch = [[UILabel alloc]initWithFrame:CGRectMake(3, 0, 100, 15)];
coinWatch.font = [self coinsFont];
coinWatch.textColor = [UIColor colorWithRed:1.0 green:0.83 blue:0.16 alpha:1];
coinWatch.text = [NSString stringWithFormat:@"%d", data.getCoins];
NSLog(@"label %d",data.getCoins);
coinWatch.backgroundColor = [UIColor clearColor];
//}
[coinsLabelView addSubview:coinWatch];
return coinsLabelView;
}
- (void) setCoin {
[coinWatch performSelectorOnMainThread:@selector(setText:) withObject:[NSString stringWithFormat:@"%d", data.getCoins] waitUntilDone:NO];
NSLog(@"coin %d",data.getCoins);
NSLog(@"Really updating");
}
我是xcode的新手,但这是我更新coinWatch(UILabel)的简单代码。标签最初为0但是当我使用其他功能添加硬币时(此处未显示),NSLog打印正确的数量但不更新...当我调用setCoin时,它不会更新中的coinWatch文本视图。请帮助这个可怜的新手!!!