Andrew
Andrew

Reputation: 16051

UIViewController isn't aware of rotation with a modal view being shown

I have a UIViewController, which launches a modal view controller. Both have orientation support. If i rotate with the modal view controller there, it doesn't tell the view controller behind it that rotation has happened, and so when the modal view controller is dismissed, the original view is in the right orientation, but at the original sizes (e.g. i rotate it to be 480x320, the text and other items will be the correct way up for the new orientation, but will still be arranged in their 320x480 layout). How do i let the view controller know rotation has occurred?

Upvotes: 1

Views: 1073

Answers (1)

zahreelay
zahreelay

Reputation: 1742

use NSNotification.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
        {
             // send a notification here
         }

In your ViewController behind, add an observer and call a method to fix the layout.

An old SO answer explaining the sytntax for NSNotification

I hope its useful

Upvotes: 1

Related Questions