Swift 在ipad2上时集合视图出现故障?

Swift 在ipad2上时集合视图出现故障?,swift,autolayout,uicollectionview,Swift,Autolayout,Uicollectionview,我在一个页面上有3个集合视图。然而,当我在iPad2上运行它时,它会加倍,如下图所示: 这就是它在iphone上的外观: 我觉得这与约束有关,但代表的代码如下: func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { return 1 } func collectionView(collectionView: UICollectionView, numberOfItems

我在一个页面上有3个集合视图。然而,当我在iPad2上运行它时,它会加倍,如下图所示:

这就是它在iphone上的外观:

我觉得这与约束有关,但代表的代码如下:

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
    }

}
func numberOfSectionsInCollectionView(collectionView:UICollectionView)->Int{
返回1
}
func collectionView(collectionView:UICollectionView,numberOfItemsInSection:Int)->Int{
如果collectionView==prodCollectionView{
//打印(“有\(prodImage.count)prodImage项”)
返回prodImage.count
}
如果collectionView==revenueCollectionView,则为else{
//打印(“有\(revImage.count)个revImage项目”)
返回revImage.count
}
否则{
//打印(“有\(accImage.count)accImage项”)
返回accImage.count
}
}
func collectionView(collectionView:UICollectionView,
布局集合视图布局:UICollectionViewLayout,
SizeFormiteIndeXPath indexPath:NSIndexPath)->CGSize{
让kWhateverHeightYouWant:CGFloat=100
返回CGSizeMake(collectionView.bounds.size.width,KWhat您想要的任何高度)
}
func collectionView(collectionView:UICollectionView,cellForItemAtIndexPath indexPath:NSIndexPath)->UICollectionViewCell{
如果collectionView==prodCollectionView{
//打印(“collectionViewOne”)
让cell=collectionView.dequeueReusableCellWithReuseIdentifier(“productCell”,forIndexPath:indexPath)作为!ImageCollectionViewCell
checkBegin[0]=indexPath.item
cell.images=self.prodImage[indexPath.item]
//collectionView.bounds=CGRect(x:,y:,宽度:,高度:)
返回单元
}
如果collectionView==revenueCollectionView,则为else{
//打印(“收集视图二”)
//打印(indexPath.item)
让cell=collectionView.dequeueReusableCellWithReuseIdentifier(“revCell”,forIndexPath:indexPath)作为!revenueImageCollectionViewCell
checkBegin[1]=indexPath.item
cell.images=self.revImage[indexPath.item]
返回单元
}
否则{
//打印(“CollectioNVieWThree”)
让cell=collectionView.dequeueReusableCellWithReuseIdentifier(“accCell”,forIndexPath:indexPath)作为!AccessImageCollectionViewCell
checkBegin[2]=indexPath.item
cell.images=self.accImage[indexPath.item]
返回单元
}
}

您将同一图像链接了两次;不可能准确地说出问题所在。是否有更多的信息可以帮助我找出问题所在?是的,请准确地解释问题所在。“然而,当我在iPad2上运行它时,它会像下图一样加倍:”这是什么意思?@NicolasMiari我附加了错误的图像,你会在第一个链接中找到该图像,这将向你展示问题