0

view Cs

How do I set the view controller at the bottom to be my initial view controller?
I checked the box saying 'is initial view controller' but it did not work. Instead it gave me an error saying: Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?

How would I fix this?

J Duh
  • 161
  • 1
  • 11
  • 3
    Possible duplicate of [iOS 7 - Failing to instantiate default view controller](https://stackoverflow.com/questions/20875823/ios-7-failing-to-instantiate-default-view-controller) – rishi Apr 17 '18 at 10:14

1 Answers1

0

It happens in Xcode sometimes. I have done following to solve the problem:

Option 1

  1. Delete your existing storyboard if there there weren't many design changes made.
  2. Create new storyboard names. For example "Main.storyboard" (same as previous).
  3. Delete whatever is there in the storyboard. If you have not deleted the old storyboard then copy the screens from there to new storyboard.
  4. Set "Is initial view controller" using the checkbox.
  5. In plist file change "Main storyboard file base name" to your new storyboard name if you are not using it as "Main.storyboard".
  6. Clean the app and build folder (ALT + CLICK on product menu).

Option 2

Add this code to AppDelegate didFinishLaunchWithOptions. Set your view controller storyboard identifier as "MyViewController" or whatever you want.

let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let yourVC = mainStoryboard.instantiateViewControllerWithIdentifier("MyViewController") as! MyViewController
appDelegate.window?.rootViewController = yourVC
appDelegate.window?.makeKeyAndVisible()
Community
  • 1
  • 1
Bidhan Roy
  • 52
  • 4