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];
}
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];
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");
applications expected to have a root view controller console
You should replace the
[window addSubview:tabBarController.view];
to
[self.window setRootViewController:tabBarController];
Maybe you built your project with 'Empty Application' and forgot to set the rootViewController
in your didFinishLaunchingWithOptions
(which exists in your AppDelegate.m).
However, if you build your project with 'Single View Application' or some other type, the project will set the rootViewController
via xib
by default (which might be a MainWindow.xib in your project).
Related Topics
Round Top Corners of a Uiview and Add Border
How to Stop Symbolicate Adding "<Redacted>" Pieces to iOS Crash Log
Swift: Navigate to New Viewcontroller Using Button
Typewriter Effect Text Animation
Swiftui Drag Gesture Across Multiple Subviews
Simulate Universal Gravitation for Two Sprite Kit Nodes
How to Change Status Bar Style - iOS 12
Disable Wkwebview for Opening Links to Redirect to Apps Installed on My Iphone
Push Notification -Didfinishlaunchingwithoptions
Maximum Number of Peripherals on Corebluetooth
Avfoundation Image Orientation Off by 90 Degrees in the Preview But Fine in Camera Roll
Toggling Airplane Mode in iOS Programmatically
Filetransfer Using Xmppframework in iOS
Create Movie from [Uiimage], Swift
Fatal Error: Nsarray Element Failed to Match the Swift Array Element Type