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.
Related
I have an iPad app which supports all orientations and has a UITabBarController managing a set of view controllers. Rotation works as expected everywhere. Keep in mind my UITabBarController is the .rootViewController of my app's UIWindow.
I now go to present a UIViewController modally from my UITabBarController. It presents well, and the status bar moves in accordance with the device's orientation. However, my UIViewController's view frame never changes (it is always in portrait dimensions, regardless of how it was presented).
This isn't an issue on iOS 8, and I thought UITabBarController would handle a modal controller on its own. Is there something I'm missing?
Bonus: ultimately this UIViewController will be transparent and reveal the app beneath it. When I try this and rotate my device, none of the regular view controllers rotate.
However, my UIViewController's view frame never changes (it is always in portrait dimensions, regardless of how it was presented).
This is expected. In iOS 7, rotation was implemented by applying a transform to the top-level view controller's view. The application of this transform does not alter the frame, which remains in portrait dimensions. In iOS 8, rotation is implemented at the window level.
Bonus: ultimately this UIViewController will be transparent and reveal the app beneath it. When I try this and rotate my device, none of the regular view controllers rotate.
The UIModalPresentationStyleFullscreen presentation style removes the presenter's view from the window while it is covered by the presented view controller. If you modify the alpha of the presented view controller's view, you'll just see black underneath.
Since UIModalPresentationStyleOverFullscreen did not exist in iOS 7, you would need to use UIModalPresentationStyleCustom with your own transition animator. Unfortunately, custom transitions with view controllers that can rotate is extremely buggy in iOS 7.
The first thing i would like to clarify is that i'm not talking about the splitview controller. I want a pop up with a navigation controller similar to the one you get when you tap the Keyboard>>Languages or Mail>>New Account.
Now this is not a popover controller, any standard framework available for this? Maybe i'm missing the obvious. The good things about this is that it has navigation controller and hence the view resizes to fit subsequent tableview lengths.
This is not a popover. It's a modalView with presentation style UIModalPresentationFormSheet
Check this link
For more presentation styles refer ModalPresentationStyle
Presentation Styles
Presentation styles available when presenting view controllers.
typedef enum {
UIModalPresentationFullScreen = 0,
UIModalPresentationPageSheet,
UIModalPresentationFormSheet,
UIModalPresentationCurrentContext
} UIModalPresentationStyle;
Constants
UIModalPresentationFullScreen
The presented view covers the screen, taking into account the value of the wantsFullScreenLayout property.
Available in iOS 3.2 and later.
Declared in UIViewController.h.
UIModalPresentationPageSheet
The height of the presented view is set to the height of the screen and the view’s width is set to the width of the screen in a
portrait orientation. Any uncovered areas are dimmed to prevent the
user from interacting with them. (In portrait orientations, this
option is essentially the same as UIModalPresentationFullScreen.)
Available in iOS 3.2 and later.
Declared in UIViewController.h.
UIModalPresentationFormSheet
The width and height of the presented view are smaller than those of the screen and the view is centered onscreen. If the device is in a
landscape orientation and the keyboard is visible, the position of the
view is adjusted upward so the view remains visible. All uncovered
areas are dimmed to prevent the user from interacting with them.
Available in iOS 3.2 and later.
Declared in UIViewController.h.
UIModalPresentationCurrentContext
The view is presented using the same style as its parent view controller.
When presenting a view controller in a popover, this presentation style is supported only if the transition style is
>
UIModalTransitionStyleCoverVertical.
Attempting to use a different
transition style triggers an exception. However, you may use other
transition styles (except the partial curl transition) if the parent
view controller is not in a popover.
Available in iOS 3.2 and later.
Declared in UIViewController.h.
I'm not sure if I can do this in this way, but let's have a try with smarter people then me.
I want to be able to move the frame of presented controller by dragging it. I'm expecting to see controller in which I've invoked the [self presentModalViewController:anotherVC animated:YES]; below the presented one. I'm seeing white background thou.
In order to achive this functionality without presenting modal view controller I could add subview i.e.:
[self.view addSubview:anotherVC.view];
But is there a way to move modal presented view controller and be able to see view from which this modal controller is presented in?
If you need to display the parent view behind the modal view, then you can use this code:
Set your anotherVC.view.frame less than your parent view.
anotherVC.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:anotherVC animated:YES];
But the visible portion of the parent view will be dimmed for preventing the interaction.
UIModalPresentationFormSheet
The width and height of the presented view are smaller than those of the screen and the view is centered onscreen. If the device is in a
landscape orientation and the keyboard is visible, the position of the
view is adjusted upward so the view remains visible. All uncovered
areas are dimmed to prevent the user from interacting with them.
Modal Presentation Styles
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.
is it possible to have a common view for both master and detail view controllers.
What if I need to add a header image(at top, the very first view) common for both the master and detail view controllers. When the device is in the portrait mode the width of the header image view has to shrink to fit to the detail view controller's view and when the orientation changes to landscape the width of the same header image view has to be expanded that is the width of it has to be 1024. Please tell me whether doing this is possible. or any workaround for this?
I'm not sure about this, but you may need to explicitly set the image using a UIImageView in your DetailViewController and your RootViewController NIB. Then, during an Orientation change (Portrait -> Landscape), the UIImageView in the DetailViewController should automatically flip with the rest of the ViewController, giving you what you are looking for.
A splitViewController must be root view controller in your application. If you add splitViewController's view as a subview of some other viewController's view, splitViewController will not get the rotation events.
For your problem, change the design of your app so that the common view appears only in detailViewController part so that it will appear in portrait mode also.
If this is not feasible, the only option you are left with is to create your own splitViewController, so that you will be capable of adding it over some other views and send the rotation events to this splitViewController when rotation occurs.