I have created a modal view in Portrait mode. when it is in lanscape mode it is not rotating.
How to rotate a modal view from Portrait to Lanscape in splitViewController?
I have a similar problem. The modal view is loaded from the DetailViewController, and when the iPad is rotated, the modal view disappears from view completely.
The closest I've come to a fix is, after rotating, to check whether a modal view was loaded, and then reload it, like so:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if(self.modalViewController)
[self.modalViewController.view.window reloadInputViews];
}
Related
iOS 8. I am presenting a view controller with presentation style: UIModalPresentationOverCurrentContext. This works great until I rotate my device, at which time the presented view is not properly adjusted.
Example: I presented over a portrait context. Entire screen covered by my new view (which has semi-transparencies). I rotate to landscape. The presented view rotates, but is now centered and remains at portrait width.
Both the presenting VC and the presented view are created in a storyboard using autolayout. Since I can't add constraints to the topmost view in a VC (right?) I'm not sure how to keep my presented view entirely covering the view below it.
This can happen if Presentation in the Segue is set to Page Sheet. In the storyboard, change the presentation to Full Screen or Over Full Screen
Since you're not using a segue, use UIModalPresentationOverFullScreen.
I have a view which is added in the form: [currentView addSubview: viewController.view];
If the view was added like [self presentModalViewController: viewController] then the view is displayed always ok, from landscape and portrait mode.
However, I can't use modal because the view needs to have transparent background and modal converts it to black.
The problem using the first method is that the nib is alway loaded in portrait mode, if the current orientation is portrait everything loads ok, and I can rotate to landscape without problem.
When my device is in landscape mode, the view is loaded as portrait again so it doesn't fit ok in screen.
I tried calling the rotation delegate methods: didRotateWithOrientation, willRotateWithOrientation, willAnimateRotation .. etc., however they don't rotate my view.
Is there any way to load the nib in a specific orientation or to rotate the view before it is added to my other view?
Unfortunately I don't think that this is possible, at least in iOS 4.
Check out this answer:
https://stackoverflow.com/a/4869207/472344
You might better off creating a custom view and adding that instead of a view controller.
NEW EDIT:
I have narrowed my problem to this - i have a view that i add to my main view. That view is nib file in portrait orientation. That view can be added both in landscape or portrait mode. After adding it as subview how do i tell it, device is now in landscape mode, you should autoresize to fit?
OLD:
/*
I have a view, that is loaded via [NSBundle mainBundle] loadNibNamed. When button show is pressed view should show, and likewise when button hide is pressed view should hide. And this works ok.
Problem is with when device orientation is changed (lets say from portrait to landscape mode). If view is shown it resizes ok, and everything works fine. But if view is hidden, and i rotate the device and press show, view is shown, but not adjusted to new layout. It retains its original dimensions.
It is as automatic resizing is only applied to visible components. Is there some way to force resizing of the view?
*/
When you add your view, use the following:
[subViewFromNib setBounds:[viewYouAddedSubviewTo bounds]];
I have an iPad Split View Application that brings up a modal view to display certain content. When I bring up the modal (in PageSheet style) and then change from Portrait to Landscape (or vice-versa) and then dismiss the modal the orientation of the detailViewController (the parent of the modal) turns 90 degrees.
So if I am in landscape mode when I close the modal the right pane will turn as if it were in portrait mode but the device is still in Landscape and the rootViewController is still visible. After this happens no rotation will solve the problem until the view is removed.
Any idea what I've screwed up here? I've had a ton of trouble with iPad rotation handling in general but this one is really giving me problems.
If you are presenting the modal view from either of the two sub-views of the SplitViewController, then you will have the orientation problems. Just present the modal view from the SplitViewController.
I have a UITableview inside a popover. Initially the popover is displayed in portrait and upon rotation to landscape it disappears as expected. When rotated back to portrait and the popover is caused to be presented again, the tableview is shown in landscape mode inside the popover. How can I prevent the tableview from rotating, or cause it to rotate back?
Keep a reference to the popover in the view controller that opens it. That view controller will receive willRotate messages. You can dismiss the popover from there.