2016-05-08 6 views
1

私はtableViewから検索してセルをタップした後にcollectionViewを表示したいと思います。ViewControllerを使用せずに表示する方法Seque

また、tableViewControllerであるsearchControllerを作成し、updateSearchResultsForSearchController()を実装します。これはうまく動作し、私が望む結果を表示します。

ストーリーボードがsearchControllerを持っていないので、私はsearchController間のセグエを作成することはできませんし、私が試したcollectionViewController.Whatは

//PostListId is the storyboard id of postList(collectionview here) 
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 
    // Choose the viewController I wanna display 
    let postList = storyboard?.instantiateViewControllerWithIdentifier("PostListId") as! PostListController 
    // Send data to collectionView 
    postList.key = 1 
    // PresentViewController 
    self.presentViewController(postList, animated: true, completion: nil) 
} 

である。しかし、私は、検索した後、セルをタップすると、私が得ましたここではエラーが表示され、エラーメッセージのフィードバックは表示されません。

+0

必要に応じてストーリーボードシーンを使用できます。 View Controllerカスタムタイプを適切に設定するだけです – Paulw11

答えて

1

このような何か試してみてください:

let postCtrl = PostListController() //create instance of your controller 
postCtrl.key = 1 
let navigationController = UINavigationController(rootViewController: postCtrl) //create navigation controller if you want 
pushViewController(navigationController, animated: true) //display 

またはあなたが好む場合は、モーダルとしてあなたのコントローラを提示することができます:あなたのコード

presentViewController(postCtrl, animated: true, completion: nil) 
0

は、今のところ、正常に見えます。ストーリーボードIDを設定してください:

image

関連する問題