I'm building an application now, 95% of the app is based around a SplitViewController
, which loads the tableView
content from a string from another view controller. Right now I got the initial view controller as the SplitViewController
, but once I change it this code causes issues in my AppDelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UISplitViewController *splitviewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitviewController.viewControllers lastObject];
splitviewController.delegate = (id)navigationController.topViewController;
return YES;
}
If I remove it, the SplitViewController
doesn't work as supposed obviously. I tried this, just to see if everything else would work; the new initial view controller loaded successfully - but once I pressed a button to modal over to the SplitViewController
again, this code is blamed with the following message:
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
Exception
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a Split View Controllers modally .'
Any idea on how to fix this? Help will be highly appreciated!
Edit:
I found this: Set your splitView as the rootView of your app, present modally your singleView at launch, and whenever you want just dismiss it to let the splitView have control. Will have the same effect than having your singleView presenting the splitView.
And that's what I thought as well. Is this a viable solution and will apple approve it during testing?