在UICollectionViewFlowLayoutBreakForInvalidSizes处创建一个符号断点

时间:2016-05-29 14:25:51

标签: ios xcode uicollectionview swift2

我在我的代码中遇到这个错误,它说“在UICollectionViewFlowLayoutBreakForInvalidSizes创建一个符号断点,以便在调试器中捕获它。”我很困惑,实际上这里问的是我正在考虑的代码,要求它放在哪里,不确定在哪里?

import UIKit

// MARK: - CUSTOM SOCIAL CELL
class SocialCell:UICollectionViewCell {

    /* Views */
    @IBOutlet weak var socialIcon: UIImageView!
    @IBOutlet weak var socialLabel: UILabel!
}

class SocialList: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {

    /* Views */
    @IBOutlet weak var socialCollView: UICollectionView!

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    // MARK: - COLLECTION VIEW DELEGATES 
    func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
        return 1
    }

    func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return socials.count //socialNames.count
    }

    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("SocialCell", forIndexPath: indexPath) as! SocialCell

        cell.socialLabel.text = "\(socials[indexPath.row]["name"]!)"
        cell.socialIcon.image = UIImage(named: "\(socials[indexPath.row]["name"]!)")

        return cell
    }

    func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
        return CGSizeMake(view.frame.size.width/3.8, view.frame.size.width/3.8)
    }

    func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
        selectedSocial = "\(socials[indexPath.row]["link"]!)"
        selectedName = "\(socials[indexPath.row]["name"]!)"
        selectedColor = socialColors[indexPath.row]

        navigationController?.popViewControllerAnimated(true)
    }
}

1 个答案:

答案 0 :(得分:37)

您可以通过以下方式系统地解决此问题:

此外,您应该分享您的完整错误,以便我可以引导您解决更具体的问题。我的想法是你在UICollectionView中有某种autoLayout问题

在项目的左侧,单击“断点”导航器

enter image description here

接下来点击左下角的加号按钮,然后点击添加符号BreakPoint

enter image description here

然后你会看到一个弹出窗口。像那样添加UICollectionViewFlowLayoutBreakForInvalidSizes

enter image description here

在此之后,只需按Enter键(在键盘上)并单击任意位置

运行代码并查看项目停止的位置