kEvin
kEvin

Reputation: 411

UIsplitview Not Respond Rotation

I am developing app using UISplitview.

When I am Rotate the device form Landscap to Portrait I set the frame but It is not set. In portrait mode only detailview is there. Landscap mode master and detail view is there.

So how can i Identify rotation in portrait mode ?

is it any kind of method is there?(like In view controller has willAnimationRotationtoInterfaceorientation)

Upvotes: 0

Views: 77

Answers (2)

Live2Enjoy7
Live2Enjoy7

Reputation: 1105

from what I understand, you want to be able to see the master in the portrait view.

The design of UISplitViewController specifically hides master view in portrait mode.

There are two ways to go about the situation here. First of all, you declare your ViewController controller as the UISplitViewControllerDelegate. (which view controller as the delegate? the one that stays in the stack - for you to figure out whether it's master or detail).

Then you have a few delegate methods to take a look at.

If you want to straight up just show the master in portrait mode in the following delegate method:

- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation

you return NO (aka you don't want it to hide the view controller)

By default, this is no for landscape, which is why you see both views, and yes for portrait, which is why you don't see the master.

Saying that, the more elegant solution would probably be to hide the master view and then put a button at the top of the navigation bar, after clicking on which, you will be shown the master in portait mode. And upon clicking outside the master view, the master will be hidden.

To do this, you do not use the above BOOL method, but implement these other two delegate methods instead:

– splitViewController:willHideViewController:withBarButtonItem:forPopoverController:
– splitViewController:willShowViewController:invalidatingBarButtonItem:

Search documentation for UISplitViewControllerDelegate.

Upvotes: 1

matt
matt

Reputation: 534950

Make a new project in Xcode using the Master-Detail Application Template for iPad. This project template creates a UISplitViewController that responds to interface orientation. Thus it shows you fully and precisely how to do what you're asking to do.

Upvotes: 0

Related Questions