私はテーブルビューを持っています。行の1つがタップされたときに別のVCに行きたいです。私のdidSelectRowAtIndexPath関数は以下の通りです。 printコマンドが機能し、右クリックされた行が表示されます。しかし、私はself.navigationController?.pushViewControllerを使用すると、playVideo storyBoardIdでvcに移動しません。それをpresentViewControllerに変更した後で動作します。プッシュが機能しないという私のコードについて何が間違っていますか?pushViewControllerは何もしません。
おかげ
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("clicked " + String(indexPath.row))
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("playVideo") as! PlayVideoViewController
vc.id = self.video[indexPath.row].id
// Present View as Modal
//presentViewController(vc as UIViewController, animated: true, completion: nil)
// Push View
//self.navigationController?.pushViewController(vc, animated: true)
}
PlayVideoViewControllerはナビゲーションコントローラのルートではないため、pushViewControllerメソッドは実行されません。あなたのストーリーボードに行くことによってナビゲーションコントローラを追加する必要があります、PlayVideoViewControllerを選択し、トップメニューでエディタ - >埋め込み - >ナビゲーションコントローラを選択します。あなたのPlayVideoViewControllerはナビゲーションコントローラのルートになり、pushViewControllerは正常に動作するはずです。 – muazhud
@muazhud私はあなたと同じことをした、とBseabornは言った。それでもまだ動作していません –