下午所有,
有没有人在iOS中使用图像全屏和水平分页处理集合视图?
当我转向风景时,我目前遇到了困难。我在这里已经阅读了很多关于这个主题的帖子,似乎找不到任何有助于解决这个问题的帖子。
当我旋转项目时,我正在查看更改并且图像在屏幕上移位。是否有任何缺乏转向的方法来解决这个问题?
由于
ps如果您需要查看任何代码让我知道,我将编辑我的问题
使用的代码:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (_startingIndexPath) {
NSInteger currentIndex = floor((scrollView.contentOffset.x - scrollView.bounds.size.width / 2) / scrollView.bounds.size.width) + 1;
if (currentIndex < [self.marbleImages count]) {
self.title = self.marbleImages[currentIndex][@"name"];
}
}
}
- (BOOL) shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
layout.itemSize = self.view.bounds.size;
[self.collectionView scrollToItemAtIndexPath:self.startingIndexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO];
}