Я использую UICollectionrView для показа видео. Все работает отлично, за исключением того, что я получаю предупреждение:Swift 2 - поведение UICollectionViewFlowLayout не определено, потому что:
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.
Это предупреждение появляется только при перезагрузке данных внутри моей коллекцииView.
Я попытался изменить ширину, но там все еще есть предупреждения.
Что я делаю неправильно?
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
}
Любое обновление по этому вопросу? –
Это сообщение объясняет, почему это происходит, а также дает решение: https://stackoverflow.com/a/39497850/4218640 – ElectroBuddha