function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ChrisXChrisX 

Mobile SDK iOS - SFNativeRestAppDelegate and UISplitViewController

Hi there,

 

In AppDelegate inherit from SFNativeRestAppDelegate

I am having problems returning a UISplitViewController in

 

- (UIViewController*)newRootViewController {

//    RootViewController *rootVC = [[RootViewController alloc] initWithNibName:nil bundle:nil];

//    UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:rootVC];

//    [rootVC release];

//    

//    return navVC;

 

    

    MasterViewController *masterViewController = [[[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil] autorelease];

    UINavigationController *masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];

    

    DetailViewController *detailViewController = [[[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil] autorelease];

    UINavigationController *detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];

    

    UISplitViewController* splitViewController = [[[UISplitViewControlleralloc] init] autorelease];

    splitViewController.delegate = detailViewController;

    splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil];

 

    return splitViewController;

}

 

 

I get 

'Application tried to present a Split View Controllers modally

 

I know that iOS require the UISplitViewController to be the rootView, but using the SFNativeRestAppDelegate?

 

Thanks


 

 

Best Answer chosen by Admin (Salesforce Developers) 
Tom GersicTom Gersic

You can just override setupNewRootViewController in AppDelegate to keep it from presenting the modal view controller:

 

/**
* Override the setupNewRootViewController from SFNativeRestAppDelegate because it presents a modal view by default, and
* we want to use a UISplitViewController (which can't be used in a modal view)
**/
- (void)setupNewRootViewController
{
    UIViewController *rootVC = [[self newRootViewController] autorelease];
    self.viewController = rootVC;
    self.window.rootViewController = rootVC;
}


All Answers

cloudcodercloudcoder

Try this: It's a pre-configed project using the splitview and mobileSDK:

 

https://github.com/quintonwall/MobileSDK-SplitView

 

Kevin HawkinsKevin Hawkins

Ah, this is a bug.  SFNativeRestAppDelegate presents the root view controller modally, which is likely what's causing the problem.  I'll take a look.

Tom GersicTom Gersic

You can just override setupNewRootViewController in AppDelegate to keep it from presenting the modal view controller:

 

/**
* Override the setupNewRootViewController from SFNativeRestAppDelegate because it presents a modal view by default, and
* we want to use a UISplitViewController (which can't be used in a modal view)
**/
- (void)setupNewRootViewController
{
    UIViewController *rootVC = [[self newRootViewController] autorelease];
    self.viewController = rootVC;
    self.window.rootViewController = rootVC;
}


This was selected as the best answer
Kevin HawkinsKevin Hawkins

Ah yes, thanks Tom.  And I don't believe that will have any adverse impact on the rest of the functionality of SFNativeRestAppDelegate.  You should be safe with such an override.

 

Cheers,

Kevin