私は iPhone 5 を所有しており、常にアプリをテストしてきました。すべて iPhone 5 デバイス、iPhone 5 および 6 シミュレーターで動作しますが、iPhone 6 を借りると、奇妙な灰色の線が表示されたり消えたりし始めました (iPhone を動かすと、それらが移動します)。コレクション ビュー セル、ボタン (すべてUIView
コンテナー内にあります) の周りに表示されます。
私はすべてを消去しましたが、まだそこにあり、セルにあるボタンを非表示にし、すべての背景と境界線の色をクリアしました。これらの行は、セルの境界線に沿ったものです。
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
switch collectionView{
case collectionViewOne!:
return collectionViewOneRows
case collectionViewTwo!:
return collectionViewTwoRows
default: return 0
}
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
switch collectionView{
case collectionViewOne!:
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("CollectionViewCell", forIndexPath: indexPath) as! CollectionViewCell
cell.backgroundColor = UIColor.whiteColor()
cell.textLabel.text = "Hempel Product"
println(Int(indexPath.row))
cell.buttonView.tag = Int(indexPath.row)
cell.buttonView.setBackgroundImage(UIImage(named: "Hempel"), forState: UIControlState.Normal)
cell.buttonView.addTarget(self, action: Selector("Action:"), forControlEvents: UIControlEvents.TouchUpInside)
cell.layer.cornerRadius = 3
return cell
case collectionViewTwo!:
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("CollectionViewCell1", forIndexPath: indexPath) as! CollectionViewCell
cell.backgroundColor = UIColor.whiteColor()
cell.textLabel.text = "Hempel Product1"
println(Int(indexPath.row))
cell.buttonView.tag = Int(indexPath.row)
cell.buttonView.setBackgroundImage(UIImage(named: "Hempel"), forState: UIControlState.Normal)
cell.buttonView.addTarget(self, action: Selector("Action1:"), forControlEvents: UIControlEvents.TouchUpInside)
cell.layer.cornerRadius = 3
return cell
default:
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("CollectionViewCell", forIndexPath: indexPath) as! CollectionViewCell
return cell
}
}
誰もこれを経験したことがありますか?
class CollectionViewCell: UICollectionViewCell {
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
var textLabel: UILabel = UILabel()
var buttonView: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
// problem sa iphone 6 crtice
contentView.backgroundColor = UIColor.clearColor()
contentView.layer.borderColor = UIColor.clearColor().CGColor
//
buttonView = UIButton.buttonWithType(UIButtonType.System) as! UIButton
buttonView.frame = CGRect(x: frame.width / 2 - frame.width * 0.3, y: 0, width: frame.size.width * 0.6, height: frame.size.height * 0.8)
contentView.addSubview(buttonView)
let textFrame = CGRect(x: 0, y: 90, width: frame.size.width, height: frame.size.height/3)
textLabel = UILabel(frame: textFrame)
textLabel.font = UIFont.systemFontOfSize(UIFont.smallSystemFontSize())
textLabel.textAlignment = .Center
contentView.addSubview(textLabel)
}
}