Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.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(在此上下文中,使用未声明的类型,<;typeName>;对于类型查找是不明确的)_Ios_Swift_Xcode_Uicollectionview_Uicollectionviewcell - Fatal编程技术网

Ios 具有多个单元格模板的CollectionView(在此上下文中,使用未声明的类型,<;typeName>;对于类型查找是不明确的)

Ios 具有多个单元格模板的CollectionView(在此上下文中,使用未声明的类型,<;typeName>;对于类型查找是不明确的),ios,swift,xcode,uicollectionview,uicollectionviewcell,Ios,Swift,Xcode,Uicollectionview,Uicollectionviewcell,在我的一个集合视图中,我必须为不同的部分使用两个单元格模板。对于这两个单元格,我都使用.xib文件。我有两个自定义类: OverprintsCollectionViewCell和OverprintsCollectionViewDetailCell 在所述集合视图位于``的视图控制器中,我使用节索引来决定使用哪个模板。代码如下所示: func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: In

在我的一个集合视图中,我必须为不同的部分使用两个单元格模板。对于这两个单元格,我都使用.xib文件。我有两个自定义类:
OverprintsCollectionViewCell
OverprintsCollectionViewDetailCell

在所述集合视图位于``的视图控制器中,我使用节索引来决定使用哪个模板。代码如下所示:

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

    if collectionView is OverprintsCollectionView {

        if indexPath.section == 0 {
            if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "twoLblCell", for: indexPath) as? OverprintsCollectionViewCell {

                // Swift compiler message in the line above:  "Use of undeclared type 'OverprintsCollectionViewCell'"

                // cell setup  

                return cell
            }
        } else if indexPath.section == 1 {
            if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "twoLblDetailCell", for: indexPath) as? OverprintsCollectionViewDetailCell {

                // Swift compiler message in the line above:  "'OverprintsCollectionViewDetailCell' is ambiguous for type lookup in this context"

                // cell setup  

                return cell
            }
        }

    }
    return UICollectionViewCell()
}
尽管存在这些错误,应用程序还是成功构建并运行。 我以前从未使用过包含多个单元格模板的集合视图,我不确定是什么导致了这个问题

在谷歌搜索了一下之后,我检查了一些东西:
-这两个文件(
OverprintsCollectionViewCell.swift
OverprintsCollectionViewDetailCell.swift
)在检查了所有内容两次(所有标识符、目标等)、清理项目、重新启动Xcode之后,都正确地设置了目标。实际上,删除项目的派生数据起到了帮助作用