What is the best way to handle iPad/iPhone views? - iphone

I'm developping an iPhone/iPad application and I want to make specific views for both iPad and iPhone. I was wondering what was the best way to select the handle the view selection.
Should I create a MainViewController with a custom push method which handle the selection (iPad or iPhone version of the view) ?
What is the best way to do that ?

If your iPhone nib is named, MyApp.xib, name the iPad nib to "MyApp~ipad.xib" (mind the lowercase "P"). The latter one will automatically be loaded for iPad.

If you want to create specific view for iPhone and iPad,when you create a new project -> Select Device Family as "Universal" .2 xib files will be created. One for iPhone and another for iPad respectively which you can use to design iPhone and iPad interface.

Related

Copied iPhone storyboard and pasted directly into iPad storyboard, but not every view controller displays correctly on iPad

I am making separate storyboards for my app on iPhone and iPad. All of the elements on both storyboards are the same, but I needed to change a few things like font size, constraints, etc.
I did Command A (select all) and Command C to copy all of the iPhone view controllers. Then I did Command V to paste all the VCs into the iPad storyboard. Most of the VCs in the iPad storyboard display with the correct iPad format, but a few of the VCs will still display with the iPhone format even when I'm using an iPad...
I made sure that the iPad storyboard was being used for the iPad device type. Any help would be greatly appreciated

Is it possible to share view controller between iPhone and iPad storyboards?

Is it possible to share view controller between iPhone and iPad storyboards?
For example in classic master-detail application we could use same master table view on ipad and iphone. How can I do this?
upd:
I want completely reuse view controller, for example for master table view we would have table view layout, visual setup, autolayout settings, IBOutlets connections, cells visual setup and outlets connections and so on. I don't want to do this twice because layouts usually are too complex and manual editing is error-prone. Is it possible?
Yes, it is possible to use the same view controller for both iPhone and iPad (storyboards). Just keep in mind the difference (e.g. there is no master-detail feature on iPhone), and make sure to trigger device specific functionality only on that particular device ...

Strategy for developing Universal IOS application

I have an iPhone application available in appstore.
Now i would like to develop Universal version of the same app.
The iPad version of the current application will be the same. Just screens will be adapted for iPad size. The behaviour won't be changed due to device type.
My question is below:
In iPhone version, there is a page which displays hotel list.
The controller class is:
HotelListViewController.m
HotelListViewController.h
the xib is: HotelListViewController.xib
Now which is best practice for making same page of iPad:
Option 1:
Just creating HotelListViewControlleriPad.xib
and using same HotelListViewController.m and .h
Option 2:
Creating HotelListViewControlleriPad.xib
creating HotelListViewControlleriPad.m and h
thanks.
You need to go by option 1, as only view differs so you need to have different xib for iPhone and iPad.
If in your controller, there is certain view related stuff then you can handle that stuff conditionally.
You can check this thread also for some interested related discussion - How to develop an universal app for iPhone + iPad without xib files?
Either go for option 1 or use the same xib and view controller class as in iPhone but make the view controller a child view controller of the full screen view controller on iPad (for example using split view controller or a custom container view controller).

Can I use a single XIB to create full-resolution interfaces for both iPhone and iPad?

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).

Adding UISplitviewController to nib file of universal app, object not showing

So I've upgraded my iphone app to a universal app and am trying to add a uisplitviewcontroller. In MainWindow-ipad.xib, when I try to drag an object to the window, uisplitviewcontroller isn't an option. Furthermore, the screen size is the iphone's dimensions, not the ipad's. How do I get this to work with the universal app?
Thanks.
Valid XHTML http://img687.imageshack.us/img687/504/screenshot20100809at436.png
So I found out how to do it. You have to convert it to an iPad nib.