Thr*_*LLC 19 xcode ios 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)
}
}
Run Code Online (Sandbox Code Playgroud)
Aks*_*kur 39
你可以通过这样做系统地解决这个问题:
此外,您应该分享您的完整错误,以便我可以引导您解决更具体的问题.我的想法是你在UICollectionView中有某种autoLayout问题
在项目的左侧,单击"断点"导航器
接下来单击左下角的加号按钮,然后单击Add Symbolic BreakPoint
然后你会看到一个弹出窗口.在那里添加UICollectionViewFlowLayoutBreakForInvalidSizes就像这样
在此之后,只需按Enter键(在键盘上)并单击任意位置
运行代码并查看项目停止的位置
| 归档时间: |
|
| 查看次数: |
19827 次 |
| 最近记录: |