你只需要把這個標籤作爲一個整體的定時器功能:
說你的標籤是在viewDidLoad中這樣定義:
- (void)viewDidLoad
{
//Do Something here
UILabel * label = [[UILabel alloc]
initWithFrame:CGRectMake(xcoordinateLabel, ycoordinateLabel, width, height)];
label.backgroundColor = [UIColor clearColor];
label.textAlignment = UITextAlignmentCenter;
label.textColor=[UIColor whiteColor];
label.text = @"TEST";
[self.view addSubview:label];
[self changeLabelText:label];
}
如果您changeLabelText與一些延遲定義爲這樣:
- (void) changeLabelText:(UILabel *)label
{
//Changing Values after 10s Delay
double delayInSeconds = 10.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
label.text = @"TESTING Change";
});
}
您的計時器功能可以代替changeLabelText
您需要聲明一個'UILabel'類變量'labelname'並在'viewDidLoad'方法中初始化它,所以你現在可以調用'self.labelname.text = @「TEST」'。 – 2015-02-24 00:20:25
不幸的是,沒有幫助:(仍然得到相同的錯誤... – overkill 2015-02-24 08:38:38