I can’t change the rootViewController

Asked

Viewed 77 times

0

Hello, take it easy on me 'cause I’m a complete beginner.

I’m trying to change the root of an application I’m trying to do. It even worked when I mentioned window!.rootViewController = centerContainer

But when I do, the menu stops working. Can someone give me a help? I believe all my complication is in Appdelegate.

class AppDelegate: UIResponder, UIApplicationDelegate {


var window: UIWindow?

var centerContainer: MMDrawerController?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    _ = self.window!.rootViewController

    let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)



    let centerViewController = mainStoryboard.instantiateViewControllerWithIdentifier("homeViewController") as! homeViewController

    let leftViewController = mainStoryboard.instantiateViewControllerWithIdentifier("LeftSideViewController") as! LeftSideViewController

    let rightViewController = mainStoryboard.instantiateViewControllerWithIdentifier("RightSideViewController") as! RightSideViewController

    let leftSideNav = UINavigationController(rootViewController: leftViewController)
    let centerNav = UINavigationController(rootViewController: centerViewController)
    let rightNav = UINavigationController(rootViewController: rightViewController)

    centerContainer = MMDrawerController(centerViewController: centerNav, leftDrawerViewController: leftSideNav,rightDrawerViewController:rightNav)

    centerContainer!.openDrawerGestureModeMask = MMOpenDrawerGestureMode.PanningCenterView;
    centerContainer!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.PanningCenterView;

    window!.rootViewController = centerContainer

    window!.makeKeyAndVisible()






    return true
}

1 answer

1

let storyboard = UIStoryboard(name: "PaginaInicial", bundle: NSBundle.mainBundle())      
let loginView: SignInVC = storyboard.instantiateViewControllerWithIdentifier("SignInVC") as! SignInVC
UIApplication.sharedApplication().keyWindow?.rootViewController = loginView
  • I have to create 1 Viewcontroller and a Cocoatouchclass file named Signinvcviewcontroller right? Ai place the Class in Viewcontroller and Storyboard ID(Signinvcviewcontroller). E place the code in Appdelegate. That’s it?

  • That’s right, buddy.

  • Return me a SIGABRT in the 'class Appdelegate: Uiresponder, Uiapplicationdelegate {'

  • I’m not treating two different Viewcontroller as root?

  • try this... http://stackoverflow.com/questions/24316966/how-to-set-the-rootviewcontroller-with-swift-ios-7

  • I can’t, I’m sure I’m calling two Roots. ( I don’t know how to work these three lines out of root. 

' let leftSideNav = UINavigationController(rootViewController: leftViewController)
 let centerNav = UINavigationController(rootViewController: centerViewController)
 let rightNav = UINavigationController(rootViewController: rightViewController)'

  • guy has no mistake, it is only follow this Tuto, this code dah right... just pay attention to the code and the name of your views.

  • Setting root is no problem, the problem is changing root using Mmdrawercontroller. I’m googlando here. But it’s awful.

  • 1

    I got it, thanks!

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.