我正在使用UI集合查看多个单元格。我正在动态显示来自Web服务的数据。每当我滚动集合视图时,数据会自动更改。我想禁用该功能。
我的代码。
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
//return [names count];
return myObject.count;
}
- (UIView *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CELL" forIndexPath:indexPath];
NSString* statusfield = [NSString stringWithFormat:@"%@",[tmpDict objectForKey:@"StatusId"]];
if([statusfield isEqualToString:@"13"])
{
[cell.mySegmentedControl setTitle:@"SEND TO ADMIN" forSegmentAtIndex:0];
[cell.mySegmentedControl setTitle:@"EVALUATE" forSegmentAtIndex:1];
}
if([statusfield isEqualToString:@"5"])
{
[cell.mySegmentedControl setEnabled:NO forSegmentAtIndex:0];
[cell.mySegmentedControl setEnabled:NO forSegmentAtIndex:1];
}
if([statusfield isEqualToString: @"1"])
{
[cell.mySegmentedControl setTitle:@"ACCEPT" forSegmentAtIndex:0];
[cell.mySegmentedControl setTitle:@"REJECT" forSegmentAtIndex:1];
}
}
当我滚动mycollection视图时。由于重新加载功能,上述段值自动更改。任何帮助将不胜感激。
答案 0 :(得分:0)
此方法可能会帮助您根据项目重新加载数据。
- (void)reloadItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths