0
我是新使用UICollectionView,因爲我一直在使用UITableView,所以我事先道歉。UICollectionView單元對齊屏幕?
不管怎樣,我有一些簡單的代碼,但由於某些原因,我還不熟悉,一些單元格被放置在屏幕之外而不是被移動到下一個級別。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
array = [ [NSMutableArray alloc] initWithObjects:@"Apple", @"Is", @"The", @"Bomb", @".com", @":D", nil];
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
return 5.0;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return array.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
UILabel *label = (UILabel *)[cell viewWithTag:100];
label.text = [array objectAtIndex:indexPath.row];
[cell.layer setBorderWidth:2.0f];
[cell.layer setBorderColor:[UIColor whiteColor].CGColor];
[cell.layer setCornerRadius:10.f];
return cell;
}
發生了什麼事與 「炸彈」 和 「.COM」 的細胞?爲什麼它切斷屏幕?
你的收藏視圖的框架是什麼?你是怎麼設定的? – rdelmar 2015-01-27 00:11:16