【发布时间】:2012-10-09 21:12:28
【问题描述】:
我有一个UICollectionViewController,当用户转动他们的 iPad 时我会加载它,以便将其置于横向。我遇到的问题是我的UICollectionViewCells 仍在加载,就好像它是纵向的一样。我在 Interface Builder 中将UICollectionViewController 设置为横向,并且我使用了一个名为CollectionViewCell 的自定义单元格类。每个单元格只包含一个图像和一个标签。
我应该在 Interface Builder 或我的代码中做些什么吗?我尝试使用CGAffineTransformationMakeRotation,但这无济于事。如果其他人以前遇到过这种情况,我将非常感激!非常感谢!
这里有一些代码供参考:
-(void)viewDidLoad
{
self.collectionView.dataSource = self;
self.collectionView.delegate = self;
}
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section
{
return listArray.count;
}
- (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView
{
return 1;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"devices" forIndexPath:indexPath];
cell.statusImage.image=[UIImage imageNamed:@"Default.png"];
cell.name.text=@"HEY !!!!!";
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(320, 420);
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(50, 20, 50, 20);
}
【问题讨论】:
标签: ios orientation ios6 uicollectionview uicollectionviewcell