我UILabels
在一个UIView
(数据库中的每条记录一个)中以编程方式生成了一些。我希望这些定期更新(比如每 5 秒一次),但由于它们是动态的,因此很难对它们进行“处理”以改变它们的值。
任何人都知道如何做到这一点?
我UILabels
在一个UIView
(数据库中的每条记录一个)中以编程方式生成了一些。我希望这些定期更新(比如每 5 秒一次),但由于它们是动态的,因此很难对它们进行“处理”以改变它们的值。
任何人都知道如何做到这一点?
创建后,我会为每个标签设置标签,将每个标签值与您从中创建它们的数组的索引并行递增。然后你可以在你为你的CADisplayLink
对象声明的任何选择器中从它们的特定视图中抓取它们
for (int i = 0; i < [arrayOfData count]; i++){
UILabel *label = (UILabel*)[self.view viewWithTag:i];
//update label
}
希望我正确理解了你的问题
there are many ways, first you need to keep a reference to the labels... an array should bee good, and it's probably better have a custom label with a model, so you actually change the values on the model and you need just to send a message to the label to redraw the content, and you can do that in this way:
[labelArray makeObjectsPerformSelector:@selector(yourMethodToRefreshTheContent)];
you can even pass a object but this mean that will be the same object for all the labels
[labelArray makeObjectsPerformSelector:@selector(valueSetter) withObject:newValue];