Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.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标头上的搜索栏实现_Ios_Swift_Uicollectionview_Uicollectionreusableview - Fatal编程技术网

Ios collectionView标头上的搜索栏实现

Ios collectionView标头上的搜索栏实现,ios,swift,uicollectionview,uicollectionreusableview,Ios,Swift,Uicollectionview,Uicollectionreusableview,我在collectionView标题中实现了一个搜索栏 我在这里得到一个例外: func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { let searchView: UICollectionReusableView =

我在collectionView标题中实现了一个搜索栏

我在这里得到一个例外:

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {

    let searchView: UICollectionReusableView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "SearchBarDispositivos", for: indexPath) 

    return searchView
}

错误消息是:源文件中的编辑器占位符。

这似乎只是一个Xcode错误。完全删除SupplementalElementOfKind的
视图,清理项目,构建项目。请再次尝试添加
视图以获得类的SupplmentalElement
。@oCal,我将尝试it@ocanal,完成后,错误消息消失,但启动应用程序时出现错误:2020-03-21 15:05:46.358118+0100 Jogua[15572:689310]***由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法将标识符为SearchBarDispositivos的UICollectionElementKindSectionHeader类型的视图出列-必须为标识符注册nib或类,或在情节提要中连接原型单元格。这是另一个错误,但您必须在viewdidload中注册该类,然后才能使用它,添加此
collectionView.register(SearchBarDispositivos.self,对于种类的SupplmentalViewofKind:UICollectionView.elementKindSectionHeader,使用ReuseIdentifier:“SearchBarDispositivos”)
@ocnal,我将尝试另一种实现搜索栏的方法。非常感谢。