1
我現在有一個集合視圖,上面有圖像網格,當選擇一個圖像時,這個圖像會嵌入另一個集合視圖上,並帶有全屏圖像。CollectionView方向問題
要做到這一點,我使用:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"collectionView"])
{
QuartzDetailViewController *destViewController = (QuartzDetailViewController *)segue.destinationViewController;
NSIndexPath *indexPath = [[self.collectionView indexPathsForSelectedItems] objectAtIndex:0];
destViewController.startingIndexPath = indexPath;
[destViewController.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO];
[self.collectionView deselectItemAtIndexPath:indexPath animated:NO];
}
}
,然後在我的局部視圖:頂部的變化
- (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.quartzImages count]) {
self.title = self.quartzImages[currentIndex][@"name"];
}
}
}
- (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];
}
當我旋轉爲橫向圖像中消失的標題,如果我返回到網格,然後再次選擇一個單元,它會再次繼續到詳細視圖,但標題是針對不同的單元格,並且圖像顯示兩個不同圖像之間的一半和一半。
我收到以下消息以及對日誌的時候我旋轉設備:
2013-06-04 17:39:53.869 PhotoApp[6866:907] the behavior of the UICollectionViewFlowLayout is not defined because:
2013-06-04 17:39:53.877 PhotoApp[6866:907] the item height must be less that the height of the UICollectionView minus the section insets top and bottom values.
我怎樣才能糾正這種因此它會支持的方向。
感謝
請參閱我的答案在這個崗位http://stackoverflow.com/questions/13902469/ios-6-supportedinterfaceorientations-issue/13902779#13902779 –
仍然無法正常工作,嘗試了三種方式,並且仍然存在相同的問題。我也收到了這個警告:2013-06-04 17:39:53.869 PhotoApp [6866:907] UICollectionViewFlowLayout的行爲沒有定義,因爲: 2013-06-04 17: 39:53.877 PhotoApp [6866:907]項目高度必須小於UICollectionView的高度減去頂部和底部值的部分。 – David