1
@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テキストが更新されません。見る。この惨めな初心者を助けてください!!!

4

0 に答える 0