0

I want to make slide out menu. For this I have to create UINavigationViewController which will controlMenuViewController(Table View) and ProfileViewController(Content View)

I want to set UINavigationViewController like a rootViewController, for this I wrote this code in AppDelegate.swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

let nav1 = UINavigationController()
        let mainView = MainViewController(menuViewController: nil, contentViewController: nil) //ViewController = Name of your controller
        nav1.viewControllers = [mainView]
self.window?.rootViewController = nav1

        self.window?.makeKeyAndVisible()

        return true
    }

MainViewController is my UINavigationViewController.

But here I have error

nil is not compatible with expected argument type 'UIViewController'

What I should do?

4
  • what is your MainViewController class type? Commented Apr 20, 2016 at 8:39
  • Actually its UINavigationViewController, but i import one library and now its look like class MainViewController:ENSideMenuNavigationController, ENSideMenuDelegate { Commented Apr 20, 2016 at 8:41
  • What's let nav1 = UINavigationController() for? Commented Apr 20, 2016 at 8:44
  • I found that one from internet when i just started this project, I forget ;( Commented Apr 20, 2016 at 8:47

3 Answers 3

1
  1. You pass nil here: MainViewController(menuViewController: nil, contentViewController: nil) instead of some view controllers. That's probably the reason it doesn't compile.

  2. You embed your MainViewController instance, which is already UINavigationController, into another one UINavigationController. That looks wrong too.

Sign up to request clarification or add additional context in comments.

1 Comment

The second point explain your line: MainViewController is my UINavigationViewController.
1

Here is an example:

LoginViewController *loginController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"loginController"]; //or the homeController
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:loginController];
self.window.rootViewController = navController;`

Comments

0

This error means you can't set menuViewController and contentViewController to nil, they are not optional

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.