我在 1 个 self.view 上有 4 个托管视图
self.hostView.frame = CGRectMake(0.0, 0.0, 512.0, 352.0);
self.hostView2.frame = CGRectMake(512.0, 0.0, 512.0, 352.0);
self.hostView3.frame = CGRectMake(0.0, 352.0, 512.0, 352.0);
self.hostView4.frame = CGRectMake(512.0, 352.0, 512.0, 352.0);
在托管视图上,我制作情节。我有 4 个包含一些数据的数组。
self.arr1 = [NSMutableArray arrayWithObjects:
[NSDecimalNumber numberWithFloat:36.23],
[NSDecimalNumber numberWithFloat:38.44],
nil];
self.arr2 = [NSMutableArray arrayWithObjects:
[NSDecimalNumber numberWithFloat:36.23],
[NSDecimalNumber numberWithFloat:38.44],
nil];
self.arr3 = [NSMutableArray arrayWithObjects:
[NSDecimalNumber numberWithFloat:36.23],
[NSDecimalNumber numberWithFloat:38.44],
nil];
self.arr4 = [NSMutableArray arrayWithObjects:
[NSDecimalNumber numberWithFloat:36.23],
[NSDecimalNumber numberWithFloat:38.44],
nil];
我使用调用方法生成器的计时器
[NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(generator) userInfo:nil repeats:YES];
-(void)generator
{
[self.bd1 removeObjectAtIndex:0];
NSInteger count=arc4random()%30;
[self.bd1 addObject:[NSNumber numberWithInteger:(20+count)]];
[graph reloadData];
[self.bd2 removeObjectAtIndex:0];
[self.bd2 addObject:[NSNumber numberWithInteger:(20+count)]];
[graph2 reloadData];
[self.bd3 removeObjectAtIndex:0];
[self.bd3 addObject:[NSNumber numberWithInteger:(20+count)]];
[graph3 reloadData];
[self.bd4 removeObjectAtIndex:0];
[self.bd4 addObject:[NSNumber numberWithInteger:(20+count)]];
[graph4 reloadData];
}
它的工作时间为 38 秒,然后冻结。我能做些什么让它正常工作。我需要重新加载数据以进行实时
有任何想法吗?