2容器视图中的UICollectionViews,只有一个滚动

时间:2015-08-26 09:15:58

标签: ios xcode swift

我有一个父容器视图,其中添加了2个不同的UICollectionViews子视图作为子视图。一个在屏幕的顶部,另一个在底部。两者都水平滚动。问题是只能滚动最后添加的集合视图(即在父视图层次结构的顶部) - 无论哪一个都无关紧要。我已经尝试将表视图和集合视图添加到同一个容器中,并且两者都是可滚动的,所以我觉得它应该适用于两个集合视图。

有什么想法吗?

class photoTapContainerVC:UIViewController {

var CIP:NSIndexPath!

override func viewDidLoad() {
    super.viewDidLoad()

    //  Create the two views used in the container view.
    var photoTapViewVC :photoTapViewController3 = photoTapViewController3(collectionViewLayout: UICollectionViewFlowLayout(), currentIndexPath: CIP)

var collectionVC:photoTapCollectionVC = photoTapCollectionVC(collectionViewLayout:UICollectionViewFlowLayout(),currentIndexPath:CIP)

    // Position/display the two views on the container view
    self.addChildViewController(photoTapViewVC)
    self.view.addSubview(photoTapViewVC.view)
    self.addChildViewController(collectionVC)
    self.view.addSubview(collectionVC.view)

让photoTapViewCellIdentify =“photoTapViewCellIdentify”

class photoTapViewController3:UICollectionViewController,UICollectionViewDelegateFlowLayout {

init(collectionViewLayout layout: UICollectionViewFlowLayout!, currentIndexPath indexPath: NSIndexPath){

    //Sets up the CollectionView and ViewFlowLayout
    super.init(collectionViewLayout:layout)

    let collectionView :UICollectionView = self.collectionView!;
    collectionView.frame = CGRectMake(0, 34, 320, 320)
    collectionView.pagingEnabled = true
    collectionView.registerClass(photoTapViewCell2.self, forCellWithReuseIdentifier: photoTapViewCellIdentify)
    self.makeBackHeader()

    layout.scrollDirection = UICollectionViewScrollDirection.Horizontal
    layout.itemSize = CGSizeMake(320, 320)
    layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
    layout.minimumInteritemSpacing = 0
    layout.minimumLineSpacing = 0

    collectionView.performBatchUpdates({
        collectionView.scrollToItemAtIndexPath(indexPath, atScrollPosition: .CenteredHorizontally, animated: false)
        }, completion: nil)
}

第二个视图控制器或多或少相同,只是不同的x / y坐标(尽管它们不重叠)。

0 个答案:

没有答案