Applications are expected to have a root view controller at the end of application launch
I had this same problem. Check your main.m. The last argument should be set to the name of the class that implements the UIApplicationDelegate protocol.
retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
Application windows are expected to have a root view controller at the end of application launch error when running a project with Xcode 7, iOS 9
From your error message:
Application windows are expected to have a root view controller at the end of application launch
How old is this "old" project? If it's more than a few years, do you still have:
[window addSubview:viewController.view];
You should instead replace it with:
[window setRootViewController:viewController];
Application windows are expected to have a root view controller at the end of application launch - even with all known issues fixed
I ran into exactly the same thing trying to add a UITableView to a single-view app. Instead, create a default Master-Detail Application project (file->new->target->...) and see the AppDelegate's implementation of didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
MDMasterViewController *masterViewController = [[MDMasterViewController alloc] initWithNibName:@"MDMasterViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
Rather than directly setting your view controller as the window's rootViewController, you need to create a navigation controller init'ed with your view controller for initWithRootViewController, then set that nav controller as the window's rootViewController. (Notice you also have to squirrel away that nav controller in a property so it doesn't get destructed).
Application windows are expected to have a root view controller at the end of application launch error only on iPad
Change the following line:
[_window addSubview:[_navigationController view]];
to:
_window.rootViewController = _navigationController;
or, if you need iOS 3 compatibility:
if ([_window respondsToSelector:@selector(setRootViewController:)]) {
_window.rootViewController = _navigationController;
} else {
[_window addSubview:_navigationController.view];
}
Related Topics
How to Animate Constraint Changes
Nsnotificationcenter Addobserver in Swift
Figure Out Size of Uilabel Based on String in Swift
Programmatically Retrieve Memory Usage on Iphone
Iphone 6 Plus Resolution Confusion: Xcode or Apple'S Website? For Development
Any Way to Pre Populate Core Data
How to Opt-Out of Dark Mode on iOS 13
Core Data: Quickest Way to Delete All Instances of an Entity
What Is the Documents Directory (Nsdocumentdirectory)
How to Change the Title of the "Back" Button on a Navigation Bar
How to Change the Name of an iOS App
Seeing Black Bars At the Top and Bottom of the Iphone X Simulator
How to Create Dispatch Queue in Swift 3
How to Resize the Uiimage to Reduce Upload Image Size