iPad: app with TabBarController not working - ipad

I have an iPhone app that works just fine on the iPhone. I am trying to get it to work on the iPad (v 1), but it won't move off the first view.
I have a TabBarController with 5 views. When I tap on the other views, they don't show. Is there something I need to do differently when using a TabBarController for the iPad?
BTW, it doesn't work on the similator either...

I'm making an assumption here but if you originally designed it for the iPhone only and want to convert it to a universal app for both iPhone and iPad, you will need to have two MainWindow.xib files. One for the iPhone and another for the iPad. And you'll have to specify those .xib files in the project settings. Set the Main and iPad interface files. An easy way to get a version of the iPad MainWindow.xib is to create a new project for the iPad and just copy it over to your own proj.

Related

iOS - Open a different Stroryboard based on the device size

I have created an app in Swift and I want it to be available in both iPhone and iPad, but I would like the iPad to have a couple different layout variables, such as bigger buttons and pictures. Using auto-layout or Size Classes with constraints wasn't working and not letting me put them where I want them, so I was wondering how to make it so that when I open the simulator with an iPad, it opens the storyboard with the different View Controller layouts. I made a duplicate storyboard so I have main.storyboard and the copy is mainiPad.storyboard for the iPad only. If this can be done, please let me know! Thanks!!
This Tutorial is the old way, when You simply add iPad suffix in the file name.
This Post is the new way, introduced in Xcode 6; You simply select the storyboard name for ipad and iphone family in application plist file.

Using iPad and iPhone storyboards in Xcode

I have created an app with a storyboard in Xcode and I now want to create an iPad version. I successfully created an iPad storyboard, but it currently runs with the code from the iPhone version.
The issue I am having is that the code for the iPhone is still running with the iPad storyboard. I would like to duplicate the iPhone code and adjust it for the iPad.storyboard, but I am not sure how to do that. Thanks.
I took a screenshot for you:
So switch the tabs and assign the appropriate storyboard. and make sure it is set to universal.
If I understand your problem, you now have two storyboards, one for iPhone and one for iPad, which are both working properly, but you want to modify part of the code just for the iPad version.
You should duplicate the classes you want to edit for the iPad version of your app and assign those new classes to the corresponding ViewControllers of the iPad storyboard.
Of course, you are still making a single, universal app.

Make an application work on both iPhone and iPad

I would like to make it so that my iPhone app also works on iPad.
If I run it using the iPad simulator it does work, but the app doesn't show up on the iPad app store, and looks really weird.
Is it possible to create another .xib file for the iPad? I know how to add a new iPad .xib file, yet I don't know how to actually change the RootViewController.xib to RootViewController_iPad.xib if the device being used is an iPad.
I already have code for finding out if the device is an iPad, and I don't want to use auto-layout, because I would like to add different things to the view if they are using an iPad (such as using different images).
I would like to make it so that my iOS applications look good on both iPhone and iPad, and have a separate .xib files for each. Is it possible to change the default .xib file from RootViewController to RootViewController_iPad?
In order to make an application work in both iPhone & iPad then need to follow below steps.
Before create an project please select universal in device section.
In application: didFinishLaunchingWithOptions: put a condition to check the device.
If the device is iPad then load the iPad screen and if the device is iPhone then load the iPhone screen.
Make sure follow the MVC pattern, So that it is easy to populate the data in both the screens.
#class has no effect on outlets or actions it only tells the compiler that there is a class with the name that follows, no information about properties, or methods is included.
If you want to have a xib for the iPad don't create a new class for it, just create a new xib and set the file's owner to be the same as the what owns iPhone xib. You then need to add a check in application: didFinishLaunchingWithOptions: to load the correct xib.
The best option though is to tell Xcode you want a universal app when you create the project.
The key point here is that it must be a UNIVERSAL application. Its a setting when you set the app up for the 1st time. You will end up with 2 UI's (story boards or xib files).
You will have to create 2 seperate UI's for ipad and iphone. You may be able to use the main class itself for most of the code but then you have to basically put code that says
if its iphone.....
if its ipad ......

Universal app iPad to iPhone

I have created an Universal app. I have designed the app for iPad. But it doesn't work in iPhone. Will it work automatically or do i have to create all nibs separately for iPhone.
Of course it will not work automatically, if your design is for iPad only it will not work on the iPhone.
You will have to create separate XIBs for the iPad and iPhone, you can use the same viewController (.h and .m file) but seperate XIBx. Just add the device modifier to the file: MyViewController.xib and MyViewController~iphone.xib or MyViewController~ipad.xib.
Ofcourse it will not work for iPhone by itself. But its not difficult to add the support for iPhone.
Create a new StoryBoard for iPhone. Then open your iPad StoryBoard, the one you already created. Select all and copy. And then open iPhone StoryBoard and paste it in. All the controls and everything you have done in the iPad StoryBoard will be added to your iPhone StoryBoard.
After that you can do modifications in iPhone StoryBoard like remove or add some new controls etc.
Hope this helps!

Create universal app using iOS StoryBoard that have different UI

I'm new with iOS and yesterday i learnt about storyboard. it works great. i refer to this link. I tried to create iPhone apps with a storyboard.
But now i want to create an universal apps, that means for iPhone and iPad. but also using the storyboard. lets say if i have the same UI, that wont be an issue. Same UI means, my iPhone UI using tab bar controller, my iPad also use a tab bar controller. I just need to point to the same class, and the result will be the same. Now, i want have a different UI. my iPhone will use a tab bar, but my iPad will use a split view.
here is my question :
is that possible to do that with device target universal? i mean iPhone with tab bar, iPad with split view.
if yes, how can i know which device is running? either i choose iPad or iPhone. How can i know i run on iPhone/iPad? what should I validate in the appdelegate?
For ipad storyboard, i drag a split view controller but i can't see any master detail whenever i run the apps. how can it be like that?
thanks. :)
If you create a Universal application (an application that supports both iPhone and iPad), Xcode will by default give you two Storyboards - one for iPhone, one for iPad. Under your target's settings you'll see a place where you can configure which Storyboard presents the main interface - you can set this separately for iPhone and iPad:
The OS will take care of loading the correct Storyboard for you.
If you want to detect in code whether you're running on an iPhone or iPad, you can use USER_INTERFACE_IDIOM(). For example:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
There's also UIUserInterfaceIdiomPad for iPad.

Resources