我创建一个创建随机值的数组和数组。并写入标签。我添加了NSTimer,但无法重新加载值。我想用计时器重新加载数据。我怎么能这样做; 我的代码在下面
NSArray *array = [NSArray arrayWithObjects:
[NSNumber numberWithInt:arc4random() % 100 * -1],
[NSNumber numberWithInt:arc4random() %(100) * -1],
[NSNumber numberWithInt:arc4random() %(100) * -1],
[NSNumber numberWithInt:arc4random() %(100)],
[NSNumber numberWithInt:arc4random() %(100)],
[NSNumber numberWithInt:arc4random() %(100)],
[NSNumber numberWithInt:arc4random() %(100)],
[NSNumber numberWithInt:arc4random() %(100)],
[NSNumber numberWithInt:arc4random() %(100)],
[NSNumber numberWithInt:arc4random() %(100)],nil];
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: 5.0
target: self
selector:@selector(selectorSwitcher:)
userInfo: nil repeats:YES];
-(void)selectorSwitcher:(NSTimer *)timer {
[array removeAllObjects];
//Label
lblNumber.text= nil;
[createview setNeedsDisplay];
[myView setNeedsDisplay];
}
答案 0 :(得分:2)
如果您在UITableView的数据源或UITableViewController中执行此操作,您需要的是:
[self.tableView reloadData];