嗨,我有一个小问题,我的UICollectionView
。我目前没有设置间距的任何设置,但我似乎有一个巨大的差距,我很担心,如果有人可以告诉我如何解决这个问题很有帮助的单元格之间的差距? id假设它非常简单。UICollectionView单元格留下巨大的空白所有设置设置为0
下面是发生了什么我CollectionViewCells
一个例子:
定制cell.h
#import <UIKit/UIKit.h>
@interface CustomCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIImageView *IconImage;
@property (weak, nonatomic) IBOutlet UILabel *IconLabel;
@property (weak, nonatomic) IBOutlet UILabel *IconDescription;
@end
groupsviewcontroller.m
#import "GroupsViewController.h"
#import "CustomCell.h"
@interface GroupsViewController()
{
NSArray *arrayOfImages;
NSArray *arrayOfDescriptions;
}
@end
@implementation GroupsViewController
{
NSString *reuseIdentifier;
}
- (void)viewDidLoad
{
[super viewDidLoad];
reuseIdentifier= @"SmallIcon";
[[self GroupsCollectionView]setDataSource:self];
[[self GroupsCollectionView]setDelegate:self];
arrayOfImages = [[NSArray alloc]initWithObjects:@"sin.png", nil];
arrayOfDescriptions = [[NSArray alloc]initWithObjects:@"Sin", nil];
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [arrayOfDescriptions count];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
[[cell IconImage]setImage:[UIImage imageNamed:[arrayOfImages objectAtIndex:indexPath.item]]];
[[cell IconLabel]setText:[arrayOfDescriptions objectAtIndex:indexPath.item]];
return cell;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
//Dispose of any resources that can be recreated.
}
- (IBAction)cellToggleAction:(id)sender {
//need to add toggle button to toggle between three different views
//small icon
//list view
//large icon
}
@end
您是否通过编程创建了'UICollectionView'? – Breek
是的,你想要的代码? –
请别的,否则我们很难帮你:p – Breek