ios 在 UICollectionViewFlowLayoutBreakForInvalidSizes 处创建一个符号断点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37511039/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 09:11:24  来源:igfitidea点击:

Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes

iosxcodeuicollectionviewswift2

提问by Three Suit Studios LLC

I am getting this error in my code it says to "Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizesto catch this in the debugger." I am confused as to what it is actually asking here is the code in which I am thinking its asking it to be put in just not sure where?

我在我的代码中收到这个错误,它说“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)
    }
}

回答by Akshansh Thakur

You can systematically solve this by doing this:

您可以通过执行以下操作来系统地解决此问题:

Also, you should share your complete error, so that I can lead you to more specific issue. My thinking is that you have some sort of autoLayout issue in your UICollectionView

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

On the left of your project, click the Break Point navigator

在项目的左侧,单击 Break Point 导航器

enter image description here

在此处输入图片说明

Next click on the plus button on the bottom left and click Add Symbolic BreakPoint

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

enter image description here

在此处输入图片说明

Then you will be shown a popup. Add UICollectionViewFlowLayoutBreakForInvalidSizes in there like so

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

enter image description here

在此处输入图片说明

After this, just hit enter(on keyboard) and click anywhere

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

Run your code and see where the project stops

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