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).
Related
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 ...
I've got an app I'm working on and I have quite a bit of data entry during user registration. On the ipad version of the app this is very simple because all the data entry fields can go on a single screen. However on the iphone version this doesn't look as clean and I was wanting to break this across 2 screens. This would require possibly switching between XIBs. So my question is can I use a single view controller and treat 2 XIBs as a single view? This way I can share a single view controller for the ipad & iphone versions of this screen and have all the business logic in a single view controller.
Yes, you can, assuming of course your XIBs are compatible with your controllers (e.g. your XIBs don't rely on properties that you controller doesn't implement). I have done this successfully without the two-page split requirement, but did not have just one controller class: I also subclassed this controller (one subclass for iPhone and one for iPad) in order to keep the small amount of device-specific logic in its own class.
For the page split I imagine that if you have a separate model object then you can have two controller instances, once for each page's XIB, and get them to work on the same data as you require.
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.
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 could not find any Navigation Based Application template in Xcode. As of now, I am just pushing the viewControllers to the stack and then building the application. I wanted to know how can we create a navigation based application where we can set a RootViewController and add the viewControllers onto it.., So that it would be easy to add the NavigationItems to the navigation bar in every view. Thanks
Here is a tutorial for it: Tutorial
How to add this tempelate: add template
Apple suggest to use split-View based application on iPad, Read below for the iOS project types.
Creating an iOS Application Project
Read the blog post
All about iPad: Resolution, UI Elements, Gestures, UX Guidelines