【发布时间】:2026-01-26 13:00:02
【问题描述】:
我正在使用 segue (searchSegue) 将 我的搜索屏幕 (SearchViewController) 连接到搜索结果页面 (PhotoStreamViewController)。
SearchViewController 是一个集合视图。每个集合视图单元格在 Xib 文件中都有一个设计。 (xib文件的类是SearchCategoryRowCell)
目前,当我通过SearchViewController 触发searchSegue 时,它工作正常。但是每当我通过SearchCategoryRowCell 触发相同的转场时,我就会得到Has no segue with identifier 'searchSegue'
SearchViewController.swift
class SearchViewController: UIViewController,UISearchBarDelegate,UICollectionViewDataSource, UICollectionViewDelegateFlowLayout{
...
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
searchRedirect(keyword: searchBar.text!)
}
func searchRedirect(keyword:String) {
performSegue(withIdentifier: "searchSegue", sender:self)
PhotoStreamViewController.searchString = keyword
navigationController?.setNavigationBarHidden(false, animated: true)
}
...
}
SearchCategoryRowCell.swift
class SearchCategoryRowCell: UICollectionViewCell {
//the method below is triggered by a click action
@objc func searchRedirection(_ sender:UIButton) {
print("we")
print(subCategoryArray[sender.tag].name)
let searchViewcontroller = SearchViewController(nibName: "SearchViewController", bundle: nil)
searchViewcontroller.searchRedirect(keyword: "otherSearchKeyword")
}
...
}
【问题讨论】:
标签: ios swift uicollectionview segue