Bins Ich
Bins Ich

Reputation: 1842

iOS Rotate View Controller when Modal View Controller rotates

I have an UIViewController A which opens another modal UIViewController B on UIButton action.

My Question is: When the current modal UIViewController B is open and did rotate - the previous UIViewController A doesn't rotate at all. This implies that when I dismiss UIViewController B - UIViewController A is still in the old state (has still the old interface orientation). Currently I am forcing A to rotate by calling a method in A when B rotates.

Is there another common way to inform other view controllers about rotation? Or what would be the proper way?

Upvotes: 4

Views: 2596

Answers (3)

michael23
michael23

Reputation: 3934

If the presentation style for your modal view is set to current context, it should rotate the view controller A. I had the problem but couldn't figure out why, it appears the settings in interface builder were overriding the ones set in code.

Try that, you can change the transition style obviously

IB Modal View Controller settings

Upvotes: 0

Marc Watson
Marc Watson

Reputation: 255

I was having a lot of issues with rotation myself. Have found a solution for all but the root view to first view.

See: Rotation issue from the first view (splash) to first viewController

This is really just notification of a device orientation change. The "libraryTableBorder" is specific to my app. Replace the code inside of the "if" and "else" to what is appropriate for your app.

Upvotes: 0

Snaker
Snaker

Reputation: 745

If you're using iOS 6, then you have (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation. Then, you just have to return the superview's device orientation.

Edit : if you're covering iOS 5, you can also check this.

Upvotes: 2

Related Questions