【发布时间】:2016-06-17 05:07:43
【问题描述】:
请帮助我如何水平添加标签和水平添加类似的按钮,但每个按钮应该像另一个部分一样在每个标签的下方对齐。 这应该在 UICollectionView 的标题中动态发生,因为标签和按钮的数量取决于我的数据。
我想做一个 excel 类型的布局,我想在标题中显示上述控件。
提前致谢!
我已经做到了-
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
UICollectionReusableView *reusableview = nil;
if (kind == UICollectionElementKindSectionHeader) {
DepartmentCollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];
for (int i=0; i<_officelist.count; i++) {
UILabel *label = [[UILabel alloc] init];
label.tag = i+1;
label.text=[NSString stringWithFormat:@"%@",_officelist[i]];
[self.roadmapCollectionView addSubview:label];
}
reusableview = headerView;
}
return reusableview;
}
OfficeList 是我的数组,其中包含我想在每个标签的索引值处显示的列表。
【问题讨论】:
-
能否请您提供您为达到上述效果而编写的代码,以便我们为您提供帮助?
-
查看我编辑的。
-
请修正语法,不清楚你在问什么。
标签: ios objective-c uicollectionview uicollectionviewcell uicollectionreusableview