2

I own a iPhone 5 and have always tested the app on it, everything works on iPhone 5 device, iPhone 5 and 6 simulator, but when I borrowed an iPhone 6 weird gray lines started appearing and disappearing (when I move the iPhone around they move and disappear) around collection view cells, buttons (which are all in UIView containers)

I erased everything and still they are there, I've hidden buttons that are in cells, putted all backrground and border color to clear ; these lines sort of follow borders of the cell.

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
    }

}

Did anyone have any experience with this?

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)   
    }
}

iphone6screen

SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
Josip Bogdan
  • 578
  • 1
  • 5
  • 15

0 Answers0