小编use*_*003的帖子

当searchController处于活动状态时,3D Touch不起作用

我已经用uicollectionview实现了3D Touch,效果很好。但是,当uisearchController处于活动状态时,3D Touch不起作用。uisearchController使用collectionView显示结果。以下帖子也出现了同样的问题: 3d Peek&Pop搜索结果

有人有同样的问题吗?谢谢

我想出了解决方案:

扩展MyViewController:UISearchControllerDelegate {

func didPresentSearchController(_ searchController: UISearchController) {
    if let context = previewingContext {
    unregisterForPreviewing(withContext: context)
    previewingContext = searchController.registerForPreviewing(with: self, sourceView: self.myCollectionView)
    }
}

func didDismissSearchController(_ searchController: UISearchController) {
    if let context = previewingContext {
        searchController.unregisterForPreviewing(withContext: context)
        previewingContext = registerForPreviewing(with: self, sourceView: self.myCollectionView)
    }
}
Run Code Online (Sandbox Code Playgroud)

}

ios uisearchcontroller peek-pop

6
推荐指数
1
解决办法
172
查看次数

标签 统计

ios ×1

peek-pop ×1

uisearchcontroller ×1