Ios 对成员'的模糊引用;collectionView';斯威夫特4
我在将UICollectionView的布局从Flow更改为Custom时遇到问题 我提到了地址 “” 我尝试将示例代码添加到现有代码中Ios 对成员'的模糊引用;collectionView';斯威夫特4,ios,swift,xcode,Ios,Swift,Xcode,我在将UICollectionView的布局从Flow更改为Custom时遇到问题 我提到了地址 “” 我尝试将示例代码添加到现有代码中 override func viewDidLoad () { super.viewDidLoad () self.setViewLayer () self.addPullToRefresher () self.addGesture () self.addDropDownView () self.getArtL
override func viewDidLoad ()
{
super.viewDidLoad ()
self.setViewLayer ()
self.addPullToRefresher ()
self.addGesture ()
self.addDropDownView ()
self.getArtList ()
self.artCollectionView.regCells (cells: ["HomeCollectionViewCell"])
NotificationCenter.default.addObserver(self, selector: #selector(self.getNotification(_:)), name: Notification.Name(Constants.GET_ARTS), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.resetArts(_:)), name: Notification.Name(Constants.GET_ARTS_RESET), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.searchArts(_:)), name: Notification.Name(Constants.HOME_SEARCH), object: nil)
if let layout = collectionView?.collectionViewLayout as? PinterestLayout
{
layout.delegate = self
}
}
extension HomeViewController: PinterestLayoutDelegate
{
func collectionView (_ collectionView: UICollectionView, heightForPhotoAtIndexPath indexPath: IndexPath) -> CGFloat
{
return photos [indexPath.item].image.size.height
}
}
但我在这里遇到了一个错误
collectionView?.collectionViewLayout as? PinterestLayout
错误状态
对成员“collectionView(\ u0:willDisplay:forItemAt:)的引用不明确
请帮助我。根据
viewDidLoad
中的其他代码,您的集合视图变量名为artCollectionView
,而不是collectionView
。在这种情况下,这个错误确实具有误导性
更改:
if let layout = collectionView?.collectionViewLayout as? PinterestLayout
致:
你能添加更多你复制的代码吗?因为我看不到将显示的单元格。对不起。我没有分析所有的代码,因为我被委派到项目中。修复了一个两天的麻烦错误!StackOverFlow很棒!非常感谢。你介意看看我的问题吗:
if let layout = artCollectionView.collectionViewLayout as? PinterestLayout