Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 对成员'的模糊引用;collectionView';斯威夫特4_Ios_Swift_Xcode - Fatal编程技术网

Ios 对成员'的模糊引用;collectionView';斯威夫特4

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

我在将UICollectionView的布局从Flow更改为Custom时遇到问题

我提到了地址 “”

我尝试将示例代码添加到现有代码中

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