I have a iPad application, which has a UITabBarController
as the root controller. From one of the tabs, I have a UIToolBar
which contains a UIBarButtonItem
, when clicked launches a Modal View.
The modal view appears in the correct size when first launched (in both landscape and portrait) however if you rotate the device, the modal view will then expand to fill the screen - regardless of how much you rotate the device from that point onwards.
I'm launching the modal view from the tab bar and I've set the ModalPresentationStyle
in the view to be presented.
This affects the ModalView regardless of whether I set it to FormSheet
or PageSheet
.
Has anyone experienced similar behaviour, if so, how did you solve it?
Many thanks
EDIT
I've also noticed that since 4.2 when using a Modal Style Page/FormSheet that the view behind the Modal View isn't dimmed out anymore - am I presenting the view wrong or is this just standard on 4.2?
EDIT 2
Code:
In my default UIViewController
I simply present the Modal view as follows:
void HandleNewMsgButtonTouch(object sender, EventArgs e)
{
PresentModalViewController(new ComposeMsgView(), true);
}
In the modal view itself, I've specified in the LoadView
override:
public override void LoadView()
{
base.LoadView ();
...
// initialser code related to the view
...
View.AutoresizingMask = UIViewAutoresizing.None;
ModalPresentationStyle = UIModalPresentationStyle.PageSheet;
ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;
}
I've overriden the ShouldAutoRotateToInterfaceOrientation
to always return true as well.
Regardless of whether I use Formsheet / Pagesheet, they both appear the correct width when first launched (whether in landscape or portrait - I'm aware PageSheet will fill the portrait view) however on rotation, the modal view will then fill the screen (as if I had presented the ModalView with FullScreen).
As stated in the comment, try this:
void HandleNewMsgButtonTouch(object sender, EventArgs e)
{
UIViewController oController = new ComposeMsgView();
oController.ModalPresentationStyle = UIModalPresentationStyle.PageSheet;
PresentModalViewController(oController, true);
}
LoadView() is too late to set the properties.
Previous content: Please post some code. The view is definitely dimmed, also in 4.2. I assume that you are setting the presentation style on the wrong controller, because "PageSheet" is transformed to fullscreen when in portrait mode.
You have to set the presentation style on the controller you want to show in the moda view and not on the one which IS showing. So if your controller to show is "oToShow" and the one you are showing from is "oCurrent", you would have to set the style for "oToShow". Try setting it to FormSheet which will always be on top and never goes fullscreen.
René