我将UISearchController的结果放在一个单独的UITableViewController(TableSearch)中。
当我们选择一行时,我希望使用navBar和tabBar显示DetailViewController,并使用返回按钮指向SearchViewController。
我试过了:
public function home(Request $request,$page='admin-home',$id=null)
{
if(!$request->session()->has('user'))
{
$request->session()->flash('errors', 'Session is expired');
return redirect('/');
}
//load the views based on roles
}
但它提供的DetailViewController没有navBar和tabBar。
我试过这个:
dispatch_async(dispatch_get_main_queue(), { () -> Void in
var viewController = UIViewController()
titreDetail = "Boo"
viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("Detail") as! DetailViewController
self.showViewController(viewController, sender: nil)
})
什么都没发生..
我怎么能这样做:
SearchTable - > SearchViewController - > DetailViewController?
谢谢!
答案 0 :(得分:0)
使用 self.navigationController?.pushViewController(viewController,animated:true)
答案 1 :(得分:0)
self.navigationController?.pushViewController(viewController,animated:true) 视图控制器是您为要推送的视图控制器创建的实例 - L.Valentine
答案 2 :(得分:0)
实际上我创建了一个委托协议,它运行得很好..
protocol SearchTableDelegateProtocol {
func didTapExtendInSearchViewControllerWithIndex(hashtag: String, inTrending: SearchTable)
}
class SearchTable : UITableViewController, UISearchResultsUpdating {
var delegate : SearchTableDelegateProtocol?
....
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("vc1")
tableView.deselectRowAtIndexPath(indexPath, animated: true)
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.delegate?.didTapExtendInSearchViewControllerWithIndex(self.filtered[indexPath.row][0], inTrending: self)
})
}
然后:
class SearchViewController : UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, SearchTableDelegateProtocol {
var resultSearchController = UISearchController()
override func viewDidLoad() {
super.viewDidLoad()
let locationSearchTable = storyboard!.instantiateViewControllerWithIdentifier("SearchTable") as! SearchTable
resultSearchController = UISearchController(searchResultsController: locationSearchTable)
resultSearchController.searchResultsUpdater = locationSearchTable
locationSearchTable.delegate = self
}
...
func didTapExtendInPhotoCollectionViewCellWithIndex(index: Int, inTrendingCell: CollectionCellOne) {
print (index)
self.performSegueWithIdentifier("hashtag", sender: "Instagram")
}
}
谢谢大家!