2012-01-09 5 views
2

iPhoneでUILabel: "lbl"アップデートが行われないのはなぜですか?繰り返しNSTimerからUILabelを更新できませんか?

...メソッド内から :

myTimer =[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(displayDataTimer) userInfo:nil repeats:YES]; 

...

-(void) displayDataTimer{ 

    NSString *temp = [textField1 text]; 

    [lbl setText:[NSString stringWithFormat:@"%d %d", j, genValue]]; 

    //[self.view setNeedsDisplay:YES];  

    j++; 
} 

THX

+1

[timer fire methods](http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Timers/Articles/usingTimers.html#//apple_ref/doc/uid/20000807-SW1)に注意してください。パラメータのないものであってはならない。 ' - (void)displayDataTimer:(NSTimer *)tim;'タイマーはメインスレッド上に作成されていますか?あなたは火の方法が実行されていることは確かですか? –

答えて

0

あなたの方法が発射されていることを確認し、あなたはそのラベルにアウトレットを設定しています(lblと名付けられています)、有線で接続されていることを確認してください。

self.lbl.text = [NSString stringWithFormat:@"%d %d", j, genValue]; 
関連する問題