ios在ViewWillAppear之后重新加载UICollectionView

时间:2016-10-04 12:01:31

标签: ios objective-c uicollectionview

我正在尝试操纵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中重新加载不起作用。有什么建议吗?

0 个答案:

没有答案