Show a translucent/transparent modal view with support for device rotation - ios

I want to show a translucent/transparent modal view that should cover the entire screen except status bar. Also, I shall be having different layouts for portrait and landscape orientation (in that modal view). I have done thorough googling and found some solutions. Below, i am summarizing them as well with their problems:
Add a view directly to the window: This works nice, but the problem
is device rotation. If I go by whatever I have experimented/learnt
so far, the UIWindow bounds do not change on rotating
the device. This poses a problem - I can't have my landscape modal
view unless until I do some sort of transformation on my view -
something which I am reluctant to. I am also not sure, whether it
will work, as I may have a webview of 1/3rd of the screen height and
full device width in portrait (rest area is translucent), and 1/4th of the screen width, full device
height (minus status bar) in landscape. I read that window changes the bounds (size and coordinate space orientation as well) of Root View controller's view bounds - can't I ask it to change the bounds of my modal view as well? After all Root controller view is also added to the window as a subview only.
Adding the modal view to the root controller
view: This is working fine for me so far with my custom root
controller based app. The problem is, I have to write my code as a
generic module, so that it can be used with different types of
applications. So, if the application root controller is one of the
out of the box container root controller ( like
UINavigationController, UITableViewController, etc ), then, is it
allowed to add a subview directly to their view ? i.e. is is not against the
Apple guidelines? While reading documentation, I read somewhere that
we should not play with standard UI controls, like Buttons.
While reading documentation, I also read it somewhere that UIAlertViews are
shown using another Window. How do we do that? is it normal to add
another window to the app? If things are as per the Apple
guidelines, I can try this approach - I shall make my modal view
the root view of another window and display that window.
What I am trying to achieve is very similar to showing UIAlertView, only in my case, I want my view to be fully customizable.
Thanks,

Related

Youtube-like video control bar in the bottom

In the youtube app there's a possibility to collapse video into a small preview window with a playback and controls while you navigating in the different parts of the app. By tapping on the window you can always switch to full screen mode again.
I wonder: what't the best approach to implement similar functionality? For now I see few options but I'm not very well aware of the implications of these options.
Note: I have an iPhone tabbar based app.
Create a popover modal view controller, that is presented on top of current navigation stack in a current tab
Create a view and stick it to the bottom of the screen.
Create a view in bounds of a tabbar controller
Create a modal view controller embedded in tabbar controller.
Just from the list I suspect that using a specialized UIView (2) would be the worst possible way to do this. But I don't know about the rest. Any advice would be greatly appreciated.

UI for dismissing View Controller presented by UIPopoverPresentationController regardless of Size Class

I have a Universal app, Xcode 7 Beta, targeting iOS 8.
I am presenting a View Controller using UIPopoverPresentationController.
When presented in any Regular Size Class (e.g. Full screen iPad in any orientation), the View Controller appears as a popover, at the size I have set in the preferredContentSize property. A tap outside the bounds of the View Controller will dismiss the popover.
When presented in Compact Width Size Class (e.g. any iPhone in portrait orientation), the "popover" will become a full screen view, sliding in from the bottom to the top.
The Problem
While an iPad popover has built-in dismissal behaviour (i.e. tap outside of the popover), "popovers" presented full-screen do not. And thus need some UI in order to provide the user with a way to dismiss the popover.
Question
What is the best (recommended?) way to present a UI such that it only appears for the Compact Width Size Class, in order to give the user an option to dismiss the (full screen) "popover" View Controller?
Discussion
One approach I have seen is to embed the [View Controller to be presented] in a UINavigationController. A bar button is added to the Navigation Bar, though whose outlet we can tell the presenting View Controller to dismiss the presentation.
However, not only does this require an extra, unwanted hierarchy for the otherwise simple presented View Controller on the iPad, but it requires environment checking (idiom? size class?) in viewDidLoad to programmatically hide the NavigationBar if a Regular Width Size Class (e.g. iPad) is being used. This strikes me as... fragile.
Another option is to do the above, but use Size Classes within Interface Builder to Install/Uninstall the Navigation elements, non-programmatically.
Thoughts?
Related link, discussing the detection of popover mode
Look at Interface Builder, you can make available any view depending on the Size Class currently running on your app :) If i remember well (because I can't check for now as I'm in a bus) you can specify a view to be available in a specific Size Class in the Property Inspector tab of the selected view. That way you just have to add a button or a navigation bar with items in your view and make it available only for Compact widths :) I'll check more specificaly today to take you some screenshots :)

Define modal view dimensions ?

I am developping a Master-Detail based iApp and I would like a specific button in the Master pane to trigger the apparition of a "settings" Form Window.
I then set my segue as "modal" and I get a form view covering the whole screen. This form comes from the bottom of the screen.
How do I get my view to appear from a slot at the top of the window and to cover, say, 2-thirds of the screen width and 3-quarters of its height?
Thanks!
You can't readily do it using the modal presentation styles, as they are fixed sizes. It is possible to work around but you need to mess around with resizing private views and it quickly starts to feel a bit fragile and messy.
It's simpler to create your own view controller at whatever size you like, add it as a child view controller and animate it into position yourself. You can even add your own background dimming view.
You lose the convenience of segues and the dismissal code, as you're no longer "presenting" the new VC, but that's not hard to recreate.

iPad Modal "Log In" View

I've never developed for the iPad before (just iPhone) and there are some views you see on an iPad that you cannot do on an iPhone. Specifically, I'm trying to create a modal 'login/register' type view and I'd like it to mimic the look and feel of the Log In view in the Zillow iPad app.
In Zillow when you press 'Log In' (or Settings for that matter), the background darkens and a window appears in the middle of the screen modally with a flip animation about it's horizontal axis. Here you are given a view containing buttons, text fields, toggle switches, etc.
Is there a cocoa class for this type of view on the iPad? Can you have a regular UIViewController not take up the entire screen and display 'on top' of the root view controller?
EDIT: Just discovered in the View Controller Attributes Inspector, under Simulated Metrics for Size, there is the Form Sheet option which looks similar to what I am going for. These will display on-top of root views?
You present the view modally, or in a storyboard, do a modal segue. In the inspector for the segue, you can change the presentation from default to "form sheet".
If you're doing the modal presentation in code, you can set the modalPresentationStyle property of the controller you're presenting to UIModalPresentationFormSheet.
As you said in your edit, in the storyboard, you can change the size of the view you want to present by setting the size in Simulated Metrics to "form sheet". However, this has no effect on what size the view will appear at run time. It's only used so you can properly layout your view visually. You need to use one of the ways I mentioned above to get the view to appear at the form sheet size.

Ipad orientation problem when a splitview is brought in

I have an application in which my first view has a label and a button..when I click the button, I bring in a split view.
The problem I am facing is that, the orientation of the split view is acting wierd. At times, it displays in landscape orientation properly and at other times, it displays in portrait orientation with half of its view cut. During this time, when I change the ipad orientations using the cmd + arrow keys, the split view goes haphazard.
I have included in my info.plist file -> Information property list " Initial interface orientation" and its value " landscape (right home button)". Other than that, I have not made any change...
The main thing which is bugging me is that, this does not happen all the time. It happens off and on.
It would be great if someone could help me out in this.
If you check the docs, I think it says that the split view should be the root view of the application. Not complying with this will likely cause 'buggy' behaviour.
If Jack is right, you should let the split view be the root view and just display your first view above it. When the button is tapped you dismiss the first view and the root view/split view will be visible.

Resources