2017-04-03 12 views
0

コードに応じて異なるViewControllerを表示するAppdelegateのdidFinishLaunchingWithOptionsメソッドにいくつかのコードがあります。このコードアニメーションを追加した後、向きが変わっても表示されません。しかし、このコードを削除するとアニメーションが表示されます。誰かがこれを修正する方法を教えてください。これがコードです。オリエンテーションオリエンテーションが変更されるときにアニメーションが表示されないSwift

 self.window = UIWindow(frame: UIScreen.main.bounds) 
    let storyboard = UIStoryboard(name: "Main", bundle: nil) 
    var vc:UIViewController 

    if (UserDefaults.standard.object(forKey: "Person") as? Bool) == nil { 

     vc = storyboard.instantiateViewController(withIdentifier: "FirstNavigationView") 

    }else{ 

     vc = storyboard.instantiateViewController(withIdentifier: "MainView") 

    } 

    self.window?.rootViewController = vc 
    self.window?.makeKeyAndVisible() 
+0

あなたがこの変更の前にRootviewControllerを設定していて、rootviewControllerで設定するための任意NavigationControllerを使用していないどのように私をさせることができますを与えますあなたのプロジェクト – Aashish1aug

答えて

1

あなたのビューコントローラに次のコードを追加してみてください

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { 
    coordinator.animate(alongsideTransition: nil, completion: { 
     _ in 
     UIView.setAnimationsEnabled(true) 
    }) 
    UIView.setAnimationsEnabled(true) 
    super.viewWillTransition(to: size, with: coordinator) 
} 
関連する問題