2012-01-09 4 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++; 
} 

들으

+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이라는 이름을 붙임) l 유선이고 그 다음에 :

self.lbl.text = [NSString stringWithFormat:@"%d %d", j, genValue]; 
관련 문제