没有加载 uicollectionview?
Not loaded uicollectionview?
未加载 collection当我在视图中添加时视图确实加载:
newsTableView.estimatedRowHeight = 44.0
newsTableView.rowHeight = UITableViewAutomaticDimension
但如果删除此代码,我的 collection 将加载到单元格中。
此表视图中单元格的代码
class UserAddFriends: UITableViewCell, UICollectionViewDataSource, UICollectionViewDelegate {
@IBOutlet weak var friendsCollection: UICollectionView!
@IBOutlet weak var userPhoto: UIImageView!
let cellReuseIdentifier = "friendCell"
var listImageForFriendsCollection: [String]!
override func awakeFromNib() {
super.awakeFromNib()
friendsCollection.delegate = self
friendsCollection.dataSource = self
listImageForFriendsCollection = []
userPhoto.circleImage()
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var cell = collectionView.dequeueReusableCellWithReuseIdentifier(cellReuseIdentifier, forIndexPath: indexPath) as! NewsCollectionView
cell.friendsPhoto.image = UIImage(named: listImageForFriendsCollection[indexPath.row])
cell.friendsPhoto.circleImage()
return cell
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return listImageForFriendsCollection.count
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
return 15
}
}
很遗憾,您的代码和描述缺少上下文。
在我看来,您似乎想要在 UITableViewCell 中显示 UICollectionView。
如果您将 UITableView 的 rowHeight 设置为 UITableViewAutomaticDimension,您必须确保 UITableViewCell 中的内容(即您的 UICollectionView)决定单元格的高度。您可以通过添加适当的约束来做到这一点,通常是通过 Interface Builder。
未加载 collection当我在视图中添加时视图确实加载:
newsTableView.estimatedRowHeight = 44.0
newsTableView.rowHeight = UITableViewAutomaticDimension
但如果删除此代码,我的 collection 将加载到单元格中。
此表视图中单元格的代码
class UserAddFriends: UITableViewCell, UICollectionViewDataSource, UICollectionViewDelegate {
@IBOutlet weak var friendsCollection: UICollectionView!
@IBOutlet weak var userPhoto: UIImageView!
let cellReuseIdentifier = "friendCell"
var listImageForFriendsCollection: [String]!
override func awakeFromNib() {
super.awakeFromNib()
friendsCollection.delegate = self
friendsCollection.dataSource = self
listImageForFriendsCollection = []
userPhoto.circleImage()
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var cell = collectionView.dequeueReusableCellWithReuseIdentifier(cellReuseIdentifier, forIndexPath: indexPath) as! NewsCollectionView
cell.friendsPhoto.image = UIImage(named: listImageForFriendsCollection[indexPath.row])
cell.friendsPhoto.circleImage()
return cell
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return listImageForFriendsCollection.count
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
return 15
}
}
很遗憾,您的代码和描述缺少上下文。
在我看来,您似乎想要在 UITableViewCell 中显示 UICollectionView。
如果您将 UITableView 的 rowHeight 设置为 UITableViewAutomaticDimension,您必须确保 UITableViewCell 中的内容(即您的 UICollectionView)决定单元格的高度。您可以通过添加适当的约束来做到这一点,通常是通过 Interface Builder。