Split View Controller Must Be Root View Controller

Split View Controller not as a Root View Controller

You can still change the root view controller if you need to. You can initially set the root view controller to show your login screen, and then replace it with the split view controller. Alternatively, you could present your login screen modally over the top of the split view controller.

Window's root view controller is not Split view controller

So this ended up being a pretty obscure issue. It seemed to be caused by the way that the iOS 8 SDK and Xcode 6 handle storyboards and size classes. I intend to file a bug report with apple but the repro steps to get this to present are simple:

  1. Create a new master/detail application
  2. Set deployment target to below 8.0 (7/7.1 works)
  3. Change application type from "Universal" to "iPad"
  4. You have to comment out this line from the generated app delegate, it will crash in an iOS 7 target:

    navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;
  5. Run on iPad simulator for iOS 7.1

The fix to this issue is to disable size classes on the storyboard. I theorize that the way that Xcode 6 and the iOS 8 SDK are handling size classes for iPad versus universal app builds causes this to not work on iOS 7 targets, but turning off size classes fixes the issue.

Using Split View Controller and Navigation Controller As Window Root View Controller Alternately

I finally found a way. I probably found the error. What i have done is cutting the branch on which i am sitting. I was releasing the view controller which i am currently in:) When viewdidDisappear called, there is no such view controller. Because i throw away it to space already.Below is my working steps. I hope it will be useful to someone. But i cant stand thinking of apple may reject my app. I wish finding a suitable way.

This is my working ultimate way of using split view controller and navigation controller as window root view controller alternately.

Firstly i defined NavigationController and SplitViewController property in AppDelegate interface.

AppDelegate.h
@property (assign,nonatomic) UINavigationController * NC;
@property (assign,nonatomic) UISplitViewController *SVC;

Secondly i assign newly created NC on AppDelegate didFinishLaunch event.

AppDelegate.m
//Creating my main screen controller
//Creating my navigation controller with my view controller instance. Then
self.NC= my_navigation_controller;
self.window.rootViewController= self.NC;

Thirdly creating a splitview controller and setting as app's root view controller

 MyMainScreen.m
-(void) OpenSplit()
{
//Creating my master view controller of SVC
//Creating my detail view controller of SVC
//Creating my SVC;
AppDelegate * app_delegate= [[UIApplication sharedApplication] delegate];
app_delegate.SVC= newly created my SVC;
app_delegate.window.rootViewController= app_delegate.SVC;
}

Fourthly releasing unused NC in viewDidLoad event of detail view of SVC.

MyDetailView.m
- (void) viewDidLoad()
{
...
AppDelegate * app_delegate= [[UIApplication sharedApplication] delegate];
app_delegate.NC= nil; //i dont need it now. i am releasing. Releasing Navigation Controller release as well child controllers. I learned with testing.
}

Fifthly managing close split view function.I used UIBarButton on NavigationBar in DetailView.

MyDetailView.m
-(void) closeSplitView
{
//Creating navigation controller with my main screen view controller
AppDelegate * app_delegate= [[UIApplication sharedApplication] delegate];
app_delegate.NC= newly_created_NC;
app_delegate.window.rootViewController= appdelegate.NC;
}

Sixthly handling unused split view controller in Main Screen viewDidLoad event.

 MyMainScreen.m
-(void) viewDidLoad
{
AppDelegate * app_delegate= [[UIApplication sharedApplication] delegate];
app_delegate.SVC= nil; //I am releasing it because i am working with NC now.
}

Pop to root SplitViewController in TabBarController - iOS

I managed to accomplish what I was trying to do, here's the code for others looking for the answer :

- (void) logout{
for(UIViewController *viewController in tabBarController.viewControllers)
{
if([viewController isKindOfClass:[UINavigationController class]]){
[(UINavigationController*)viewController popToRootViewControllerAnimated:NO];
}
else if([viewController isKindOfClass:[UISplitViewController class]]){

UISplitViewController *splitView = (UISplitViewController *)viewController;
for (UIViewController *navControllerInSplit in splitView.viewControllers) {
if([navControllerInSplit isKindOfClass:[UINavigationController class]]){
[(UINavigationController*)navControllerInSplit popToRootViewControllerAnimated:NO];
}
}
}
}

}



Related Topics



Leave a reply



Submit