我正在尝试操纵UICollectionView。
viewDidLoad
中的代码:
- (void)viewDidLoad {
[super viewDidLoad];
UINib * cellNib = [UINib nibWithNibName:@"NibCell" bundle:nil];
[collectionView registerNib:cellNib forCellWithReuseIdentifier:@"CvCell"];
UICollectionViewFlowLayout * flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setItemSize:CGSizeMake(50, 100)];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
[collectionView setCollectionViewLayout:flowLayout];
}
在viewWillAppear
我正在呼叫
appearCallService
下载json并更新数组。我甚至在viewWillAppear中调用reload方法但仍然无效。
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
hourlyTemperature = [[NSMutableArray alloc] init];
if ([Globals NetworkStatus]==YES) {
[NSThread detachNewThreadSelector:@selector(appearCallService) toTarget:self withObject:nil];
}
[collectionView reloadData];
}
HourlyTemperature
是我的数组,在viewDidLoad
中为空,但仍然在viewWillAppear
中重新加载不起作用。有什么建议吗?