【发布时间】:2015-03-23 10:28:18
【问题描述】:
我试图让单元格尽可能宽,但我最终是这样的:
我尝试在 xcode 中删除边距、行距等:
但水平边距仍然很大,我想要应用相同的垂直边距。
有什么想法吗?
附上示例代码:
- (void)viewDidLoad {
[super viewDidLoad];
self.collectionView.delegate = self;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 9;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
CollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor whiteColor];
return cell;
}
【问题讨论】:
-
您对此解决方案有何看法:stackoverflow.com/questions/13780138/…?
-
您似乎要求单元格大小为 100 x 100?
-
@skyline75489 是的,我正在尝试覆盖它。我将它拖到视图中,它变成了 100x100
标签: ios objective-c cocoa-touch uicollectionview