I am using a UICollectionrView to show videos. Everything works fine except that I get a warning saying :
2015-10-30 14:00:39.893 test[6451:90574] the behavior of the UICollectionViewFlowLayout is not defined because:
2015-10-30 14:00:39.893 test[6451:90574] the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values.
2015-10-30 14:00:39.893 test[6451:90574] The relevant UICollectionViewFlowLayout instance is , and it is attached to ; layer = ; contentOffset: {0, 0}; contentSize: {320, 0}> collection view layout: .
2015-10-30 14:00:39.894 test[6451:90574] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
This warning appears just when I reload the data inside my collectionView.
I have tried to change width but the warning stills there.
What am I doing wrong?
var UserVideosInfo = [[String]]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
NSNotificationCenter.defaultCenter().addObserver(self,
selector: "reloadCollectionVideoView:",
name: "ReloadCollectionVideoView",
object: nil)
}
@objc func reloadCollectionVideoView(notification: NSNotification) {
UserVideosInfo = NSUserDefaults.standardUserDefaults().objectForKey("UserVideosJSON") as! [[String]]
print(UserVideosInfo)
collectionView?.reloadData()
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if UserVideosInfo.count == 0 {
return 0
}else{
return UserVideosInfo.count
}
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let videoCell = collectionView.dequeueReusableCellWithReuseIdentifier("VideoCell", forIndexPath: indexPath) as UICollectionViewCell
let communityViewController = storyboard?.instantiateViewControllerWithIdentifier("community_id")
videoCell.frame.size.width = (communityViewController?.view.frame.size.width)!
videoCell.center.x = (communityViewController?.view.center.x)!
return videoCell
}