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?
Asked
Active
Viewed 1,069 times
1
-
The `UIViewController` being displayed modally does not normally "tell" the presenting controller about rotations. Rotations are handled automatically, provided that `-shouldAutorotateToInterfaceOrientation:` returns `YES`, even when the controller is not currently being displayed. Are you using a `UINavigationController`? If any of the view controllers on the stack do not support autorotation, the views will not rotate. In any case, while there are hacks you can use to force rotation, your best bet is to fix the underlying problem, but without more detail it's hard to tell what's going wrong. – Brian Gesiak May 13 '12 at 01:15
1 Answers
1
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
-
But what would I put as the name? What would trigger it to get it to happen? – Andrew May 13 '12 at 00:53
-
use any name, if its same in NOtification and observer, it will trigger – zahreelay May 13 '12 at 00:54