thesimm
thesimm

Reputation: 774

UISplitViewController shouldHideViewController for iOS 4.3

I'm converting my iPhone app to iPad and using

-(BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
{
    return NO;
}

to keep the dual-pane layout at all times. Unfortunately this was introduced in iOS5. I've seen mention of doing this programatically for pre-iOS 5 but not managed to find any example code. Has anyone got any pointers please?

Upvotes: 0

Views: 505

Answers (1)

CocoaEv
CocoaEv

Reputation: 2984

this area is a bit of a slippery slope because Apple has been tweaking the splitview in 5.0, 5.1 and rotation in 6.0

Not to be flip, but if you can just move your app to require 5.0, it would be the simplest way to achieve your goal.

if you want to do this your self, you would basically need to hijack the popover and re-implement in your own frame. There is a method called:

- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)newpopoverController

in this method, you can grab the viewController and store it.

then sensing when in portrait using:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

, you need to grab the detail view and adjust it - making room for your new frame on the left, which you fill using the view controller you grabbed the reference from in the previous method.

its a bit of a juggling act.

If you really, really need to stay with 4.3 compatibility and you want that feature, I'd suggest you look at an open source SplitView Controller called MGSplitViewController by Matt Gemmell - you can find it here: https://github.com/mattgemmell/MGSplitViewController.

His implementation is quite nice and will not only give you that feature, but several other options related to view position on the screen.

Now here is where the slippery slope begins though, Matt hasn't updated the code for a couple of years (although there are some forks that have) and may become difficult to maintain as you move your application forward.

If nothing else, it does contain code that does exactly what you want to do, so it would be an excellent reference to help you with your project.

sorry I can't provide a complete recipe, but really, that library should help regardless if you use it or just user it as a reference.

best of luck

Upvotes: 1

Related Questions