在ipad2上收集视图有问题?

时间:2016-01-29 01:12:10

标签: swift autolayout uicollectionview

我在一个页面上有3个集合视图。然而,当我在ipad上运行它时,它会像下面的图像一样翻倍:

This is the faulty view

它应该是这样的,它在iphone上的作用:

This is what it should look like

我感觉它与约束有关,但代表的代码是这样的:

func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
    return 1
}

func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    if collectionView == prodCollectionView {
         //print("There are \(prodImage.count) prodImage Items")
        return prodImage.count
    }
    else if collectionView == revenueCollectionView {
        //print("There are \(revImage.count) revImage items")
        return revImage.count
    }
    else{
        //print("There are \(accImage.count) accImage items")
        return accImage.count
    }

}
func collectionView(collectionView: UICollectionView,
    layout collectionViewLayout: UICollectionViewLayout,
    sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
        let kWhateverHeightYouWant: CGFloat = 100
        return CGSizeMake(collectionView.bounds.size.width, kWhateverHeightYouWant)
}

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    if collectionView == prodCollectionView {
        //print("collectionViewOne")
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("productCell", forIndexPath: indexPath) as! ImageCollectionViewCell
        checkBegin[0] = indexPath.item
        cell.images = self.prodImage[indexPath.item]
        //collectionView.bounds = CGRect(x: <#T##CGFloat#>, y: <#T##CGFloat#>, width: <#T##CGFloat#>, height: <#T##CGFloat#>))
        return cell
    }
    else if collectionView == revenueCollectionView{
        //print("CollectionViewTwo")
        //print(indexPath.item)
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("revCell", forIndexPath: indexPath) as! revenueImageCollectionViewCell
        checkBegin[1] = indexPath.item

        cell.images = self.revImage[indexPath.item]
                    return cell
    }
    else {
       // print("CollectioNVieWThree")
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("accCell", forIndexPath: indexPath) as! AccessImageCollectionViewCell
        checkBegin[2] = indexPath.item
        cell.images = self.accImage[indexPath.item]

        return cell
    }

}

0 个答案:

没有答案