Create universal app using iOS StoryBoard that have different UI - ios

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.

Related

Is it possible to support iPhoneX for some view controllers in the app?

I have an application which developed before iPhone X release. My question is the following, can I add iPhoneX support for only newly created view controllers? I mean some view controllers will have iPhoneX friendly UI some not in the same app. For my new view controllers I'm using safe area but UI is broken for iPhoneX.
For the app I guess Apple will not allow partial support for iPhoneX.
Just wondering is it possible or not and how if answer is yes.
It's either all or none. If your app uses a Launch Screen storyboard and is built with a Base SDK of iOS 11 or if your app uses launch images and includes an iPhone X launch image then your whole app is presumed to work on an iPhone X. You will need to make sure all screens work correctly.
Think about what a terrible user experience it would be to use an app on an iPhone X where some views use the whole screen and some views only use part of the screen.

How to Convert iPhone app to support iPad

I have existing iPhone app. Now i want it to give support for iPad app i Followed the below link (Converting Storyboard from iPhone to iPad). After implementing the suggestions given by tharkay. I run the app in iPad only Navigation bar coming properly but all components(like buttons, labels)are not resizing those are coming as iPhone size.
Can anybody help me to solve the problem?
Under your Project->Targets->General->Deployment Info make sure that in your iPad tab the right Main Interface is selected (it's your iPad storyboard name).
Use autolayout to setup the constraints on the UI Elements so that they can respond appropriately to different screen size like in your case iPad. Check out this link !
http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1

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.

Embed iPhone xib in iPad UIView?

I'm developing 2 iOS apps; a iPhone app and an iPad app. Both have different purposes and functions, but I'd like to (once it's complete) embed the iPhone views into the iPad app as a preview.
(in the iPad app) I have a tab view controller, it loads various controllers and the last one will be a Preview. I'd use half (landscape mode) of the screen for some final settings and the other half to preview what will be produced.
My questions are:
Is this doable?
Is it allowed by Apple?
I've seen other discussions where people want to embed other, App Store apps from other developers. I'm not trying to do this; I only intend to embed the app I have the code for.
I'm just not sure the direction to look in to get this answer.
You should put both of them in the same project, and use a simple iPhone/iPad in AppDelegate.m to start the app with the appropriate View Controller.
That way you can present the iPhone app within iPad app by simply showing a view controller. Apple won't reject since technically it's still only 1 app.
To produce and submit 2 apps from the same project, create another Target. You can set bundle identifier / device type / etc per Target.

iPad: app with TabBarController not working

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.

Resources