Im my app, i'm using split view controller for the first time. Am converting my iPhone app to universal app. My question is, how should i design the UI for the detail view controller so that it accommodates in the smaller area of the split view controller? That is, my detail view controller .xib file is in normal size landscape mode and when i design UI(insert textfields, labels, etc), they get overlapped. Any hint regarding UI Design for detail view controller?
Traditionally is the splitview master view displayed in a navigation view controller on the iphone. If the user selects any details to diaplay, thé phone display another view. This designpattern is very common and straight foreward.
Create a new project in XCode. Select a master detail template and make sure you use universal for the targets. Explore the new project.
Related
If you scroll down a bit at this Apple Developer Page you'll find the section "Creating an Alternate Landscape Interface". The basic approach described there is to present a different NIB file as a modal view when orientation changes. I am using the Storyboard feature, so I don't have NIBs. How do I load a different "scene" in that case?
Besides that, I am using a Tab Bar controller, I don't want to show a modal view. I just want to replace the current portrait view with a landscape view designed with interface builder and keep my tab bar. What would be the Storyboard way to achieve the task "Creating an Alternate Landscape Interface"? Thank you.
When you add a view controller to the storyboard it comes with a view. Call that the container view. Add two views to the container view: a portrait view and a landscape view. Set the dimension of the portrait view and the landscape view appropriately using the size inspector. Add buttons, more views, labels or whatever to the portrait and landscape views as needed for your application. Then when the orientation changes hide one view and show the other.
You can setup a navigation controller and one main view. Then you can use a template view for the portrait and landscape layouts (2 additional views).
You will need to setup the controls on the main view and make sure each one has a unique tag. Your main view will not be used, instead you will copy the controls to the two template views and set them up based on how you want each view to look. The benefit to this is each view will retain its tag which becomes a very important piece of this implementation.
Doing this you use a hybrid approach in regards to writing some UI code and using Interface Builder. After getting the two templates setup, create a unique identifier for each one. You will have to write some logic to handle the view and its subviews. A recursive method to return a collection of these based on the template you choose.
The core logic in the root view controller implementation will need to check for isPortrait and based on this you will want to load the correct view based on the identifier.
Experiment with this concept and see if it works for you. The main benefits to not using two separate views with unique controls (not the shared approach with same tags) is that you maintain access to your original subviews. Any instance variables you define in your view controller that points to a text filed, label, etc... continue to do so regardless of which template view is used. This maintains the model, view, controller approach as the data structure remains unchanged.
Using this approach you can still maximize the use of interface builder, and layout the templates for each view, while still having the flexibility to to write some custom UI code if you desire. Using only interface builder can be a bit limiting at times, and writing custom code based on orientation locks you in to a bit of tedious work.
Hope this helps some.
You can make a xib file that contains 2 uiviews, one fore portrait and one for landscape.
Assign as file's owner of the xib, the same viewcontroller of the view thet you have in the storyboard.
In viewDidLoad load the xib file, and add the appropriete view for portrait or landscape.
So if you have a storyboard with many viewcontrollers, you can set the two possibility (portrait or landscape view) only in the viewcontrollers that you are interested to change the orientation.
I used this solution and work very fine !
I want to load in an UISplitView an iPhone XIB, but it should be resized to full screen of the iPad... How can i do it? I dont want to convert the XIB itself!
I have read all the other solutions, but I do not want a second XIB, I just want to show it on both devices iPhone and iPad in its specific size.
So if I load it on the iPad by using the UISplitView, it should be in the full size, and if I load it on the iPhone, it should only have the iPhone size.
First off, there's no such thing as a UISplitView.
From the documentation:
The UISplitViewController class is a container view controller that manages the presentation of two side-by-side view controllers. You use this class to implement a master-detail interface, in which the left-side view controller presents a list of items and the right-side presents details of the selected item. Split view controllers are for use exclusively on iPad devices. Attempting to create one on other devices results in an exception.
So UISplitViewController is just a container. You just pass a master view controller and a detail view controller to it. The master view will be displayed in a popover controller in portrait orientation.
I think either I misunderstood you or your approach is wrong. The reason why this class is not supported on the iPhone is because it wouldn't make any sense. You can't just "resize the splitview" or whatever, you have to redesign your interface separately for the phone. It's difficult to give you any concrete suggestion without knowing what you're doing. Figure out what are you trying to achieve, have a design, make separate nibs for each device and try to reuse code and views as much as possible.
Matt Gemmell wrote a SplitViewController that you can use as subview for the iPad (http://mattgemmell.com/2010/07/31/mgsplitviewcontroller-for-ipad/). You can check the source if you could use this for iPhone too. I found the source too heavy, I simply created an UITableView that loads other views when selecting a row (sort of a fake splitview).
I have a uisplitviewcontroller which loads a UIWebView as its detail view. I would like to allow the use to hide the RootViewController so that they can use the detail view controller in full screen.
The behavior is similar to that used by the Dropbox application. I'm not sure how to get this done. I've tried creating a new view controller and copy the webView, but there are issues whenever the user zooms the web view.
You can customize the default split view only to a certain level..
Here are some related questions from SO:
Hiding master view in split view app..???
Ipad Split view controller
but i think you've already read them.
I would suggest you to create your own custom controller as the default split view has very limited functionality.
You can look at MGSplitViewController. It is a really good custom implementation similar to the UISplitViewController with much more flexibility.
I have an app where the appDelegate has a UITabBarController. Each of the tabs has a navigation controller which I currently use to push a single detail view onto the stack in each tab. I am hoping to replace my navigation controller on each of the tabs with a splitViewController. I use the Interface builder to provide the UINavigationController for each tab. I am having trouble loading a nib for each tab that has a UISplitViewController in it. I am getting an instance of the UITableViewController class displaying on the screen, but I am not getting the UISplitviewController or the Popover or the detail view etc. These classes are all working in a standalone app, but I am not able to get them into each of the tabs in one app. Although I am currently using the Interface Builder I am open to doing this programmatically. If someone has suggestions, or an example small project of a Tab based app with individual split views in the tabs I would appreciate it very much. (As this is my first question I am not sure how much code or other pictures from IB would be helpful for me to post. If you need further detail please let me know and I would gladly amend this post.)
Apple documentation
"The split view controller’s view should always be installed as the root view of your application window. You should never present a split view inside of a navigation or tab bar interface."
Moving on...
Not only shouldn't you -- if you do so, an error is thrown when you run. It's impossible.
I am trying to develop an app which can have multiple views (up to 30). Each view will have have similar navigation but the content will be different. Do I have to create 30 view controllers or can I get around by creating a view controller for the data (content) alone. I am sure creating multiple view controllers is going to be inefficent. I will be using the UINavigationController for sure.
Any information, links would be really appreciated.
Thanks
Amy
One view should be enough. Similar to Contacts application you have table view with each row containing different contact but when you select a name you are shown view with the details of the specific contact.
The view is the same for every contact but the data are specific for the contact.
You reuse the same view but you populate it with different data.
More info on UINavigationController and UIViewController in View Controller Programming Guide for iPhone OS.
You can place a UIView in the center part of your window for the content. This view should fill the space not taken up by your navigation bar. You can then switch the content in this view by adding a subview to it or by changing the content inside.