2017-02-26 6 views
0

私のストーリーボードには2つのView Controllerがあります:viewController1(入力ポイント)とviewController2です。アプリケーションをロードした後、私はviewController1の後に自動プレゼンテーションviewController2を出したいと思います。自動プレゼンテーションView Controller


どうすればいいですか?あなたは第二のViewControllerに行きたい場合は、viewDidLoadメソッドあなたにこのコードを追加することができ

override func viewDidLoad() { 
    // ... 
    self.present(viewController, animated: true, completion: nil) 
} 

答えて

2

0

あなたは次のようにfunc viewDidLoad() {}でそれを表示しようとしたことがあり追加する

let secondViewController = self.storyboard?.instantiateViewController(withIdentifier: "yourIdentifier") as! secondViewController 
     self.navigationController?.pushViewController(secondViewController, animated: true) 

思い出してくれるしストーリーボードの2番目のviewcontrollerの識別子と "yourIdentifier"で使用する識別子をチェンジする

アニメーションを挿入したくない場合は、アニマted:真に偽になります。

あなたはストーリーボードあなたに行くと第二のViewControllerをクリックして、拳のViewControllerを表示したいいけない場合、その属性インスペクタの右側に画像INTボックスを選択:

の場合をあなたは、あなたがそれを行う方法がわからない場合は、ナビゲーションコントローラを持つ最初のViewControllerを埋め込むだけで・ファーストのViewControllerを選択し、画像のように行い、ナビゲーションコントローラに

をクリックする必要がViewControllerを変更
0

別のView Controllerをまっすぐにロードする場合は、アプリデリゲートでこれを行うことができます。

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
    // Override point for customization after application launch. 
    let storyboard = UIStoryboard(name: "Main", bundle: nil) 
    let vc = storyboard.instantiateViewController(withIdentifier: "put your identifier here") 
    self.window?.rootViewController = vc 
    return true 
} 
関連する問題