でヘッダーの動作を模倣するためにUICollectionView
使用しています。ヘッダーの内部には、 上の制御データがあります。だから私が欲しいのは、セグメントをタップして(APIを呼び出して)データをリロードして実行することですが、常にCSStickyHeaderFlowLayout
UITableView
SegmentedControl
UICollectionView
reloadData
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
reloadData
ヘッダーもリロードするとセグメントが最初の状態に戻るため、ヘッダーではなくデータのみをリロードする最善の方法は何ですか。
ここに私のコードがありますviewForSupplementaryElementOfKind
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
UICollectionReusableView *reusableView = nil;
if (kind == UICollectionElementKindSectionHeader) {
SegmentHeaderView *collectionHeader= [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"Header" forIndexPath:indexPath];
HMSegmentedControl *segmentedControl = [[HMSegmentedControl alloc] initWithSectionTitles:@[@"Popular", @"Lelang"]];
[segmentedControl setFrame:CGRectMake(0, 0, self.view.frame.size.width, 45)];
[segmentedControl addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged];
segmentedControl.backgroundColor = [NConfig FlatButtonGray];
segmentedControl.selectionIndicatorColor = [UIColor whiteColor];
segmentedControl.selectionIndicatorBoxOpacity=1;
segmentedControl.titleTextAttributes = @{NSForegroundColorAttributeName : [NConfig FlatButtonOrange]};
segmentedControl.selectedTitleTextAttributes = @{NSForegroundColorAttributeName : [NConfig FlatButtonOrange]};
segmentedControl.selectionStyle = HMSegmentedControlSelectionStyleBox;
segmentedControl.selectedSegmentIndex = HMSegmentedControlNoSegment;
segmentedControl.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationNone;
segmentedControl.shouldAnimateUserSelection = NO;
[segmentedControl setSelectedSegmentIndex:0 animated:YES];
[collectionHeader addSubview:segmentedControl];
reusableView = collectionHeader;
}
return reusableView;
}
何かアドバイス?:)