Reputation: 1901
i am using page view controller that contain three view controller and one of the view controller has a button on which i used a push view to present another view that comes from right. every thing is working fine and view is animated and present. But the problem is that new view is presented ) over the view that is in the uipageview controller and swipe right present the second page view. i want to open new view using transition as a separate view . So i guess calling it as root vie solves the issue i guess
here is my code
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc : drawer = storyboard.instantiateViewControllerWithIdentifier("drawerID") as! drawer
hidesBottomBarWhenPushed = true
let transition: CATransition = CATransition()
let timeFunc : CAMediaTimingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.duration = 0.25
transition.timingFunction = timeFunc
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromRight //kCATransitionFromLeft
self.navigationController!.view.layer.addAnimation(transition, forKey: kCATransition)
self.navigationController!.pushViewController(vc, animated: false)
code after modifications
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc : drawer = storyboard.instantiateViewControllerWithIdentifier("drawerID") as! drawer
var nav = appDelegate.window?.rootViewController as? UINavigationController
nav = UINavigationController.init(rootViewController:vc )
hidesBottomBarWhenPushed = true
let transition: CATransition = CATransition()
let timeFunc : CAMediaTimingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.duration = 0.25
transition.timingFunction = timeFunc
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromRight //kCATransitionFromLeft
nav!.view.layer.addAnimation(transition, forKey: kCATransition)
appDelegate.window?.rootViewController = nav
appDelegate.window?.makeKeyAndVisible()
Upvotes: 0
Views: 1341
Reputation: 776
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewControllerWithIdentifier("drawer")
appDelegate.navigationController = UINavigationController.init(rootViewController:initialViewController )
appDelegate.navigationController?.setViewControllers([initialViewController], animated: false)
appDelegate.window?.rootViewController = appDelegate.navigationController
appDelegate.window?.makeKeyAndVisible()
Upvotes: 3