Tom*_*voy 5 orientation ios ios6 uicollectionview uicollectionviewcell
我有一个UICollectionViewController当用户打开自己的iPad,我加载,从而把它变成横向.我遇到的问题是我的UICollectionViewCells仍然像纵向一样装载.我UICollectionViewController在Interface Builder中设置了to landscape,我正在使用我调用的自定义单元类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);
}
Run Code Online (Sandbox Code Playgroud)
如果其他人也遇到过这个问题,这就是我解决它的方法。
\n\n我最初不允许自动旋转,而只是orientationChanged使用NSNotificationCenter. 这非常有效,只是它阻止了我的第二个视图意识到它需要以横向模式加载。
因此,我\xe2\x80\x99已经为tabBar我的主视图嵌入其中创建了一个类,并且我返回NO该类shouldAutoRotate和每个其他视图中的方法,除了我想在横向加载的视图之外模式。我\xe2\x80\x99m 仍在orientationChanged我的主视图\xe2\x80\x99S 控制器中使用通知,因为它嵌入在tabBar. 但我\xe2\x80\x99m 只是在返回主视图时使用自动旋转。
如果有人有任何疑问,请告诉我。希望能帮助到你!
\n| 归档时间: |
|
| 查看次数: |
1752 次 |
| 最近记录: |