I'd like to take my existing iPhone app and modify its layout/number of screens for an iPad.
I began by duplicating the Target with "Duplicate and Transition to iPad".
But I'm unsure where to go after that. I'll need a new Storyboard and some of the functions/viewControllers/views will need to be modified. Where/how do I do that?
All I can find are very old solutions that are no longer valid or leave too much out:
How to convert iPhone app to iPad app
This is the best one I've found, but again not current and still leaves a lot out:
http://innovationm.co/convert-iphone-application-to-universal-application/
I no longer see a "Universal" option. I am guessing that selecting all of these accomplish the same thing?
First, edit your target to make sure it is set for both iPhone and iPad:
Second, using two different storyboards is unusual nowadays, but you can easily do it. In your Info.plist configure two entries (using Raw Keys and Values): UIMainStoryboardFile and UIMainStoryboardFile~ipad. The result is that your app will load one storyboard for an iPhone and a different storyboard for an iPad.
Note that with a newer created project that uses window scenes under iOS 13 and later, you would configure UIApplicationSceneManifest and UIApplicationSceneManifest~ipad to specify different UISceneStoryboardFile values.
Here's a downloadable project that demonstrates the newer structure:
https://github.com/mattneub/Programming-iOS-Book-Examples/tree/master/bk1ch09p358universal
Related
I'm developing a universal iOS app that has some settings that make no sense for certain devices. Specifically, I'd like to hide certain settings from the user on devices where the portrait width is below a threshold. (So, for instance, some settings should not be available on an iPhone 7 but should be available on an iPhone 7 Plus.)
I'm aware that it's possible to have different settings for iPhone and iPad devices (as described in this thread), but that's not what I'm after. I'm also familiar with size-class-specific layouts, but that doesn't seem applicable to settings.
Is it possible to hide (or at least disable) certain settings based on the dimensions of the device on which the app is running?
Along the same lines, is it possible to have the default values for settings vary according to the display dimensions?
Sorry but it's impossible. You are right that all that you can is to have different settings.bundle for iPads and iPhones. Since iOS 4 Settings plists can be device-dependent: Root~ipad.plist will be used on iPad and Root~iphone.plist on iPhone. If not existed, Root.plist will be used.
So from my point of view you can achieve part of your goal using this 2 settings filed. For more specific cases you can set some default values when app launched. Settings.bundle can't be modified directly from code, so you can't remove or disable specific setting but you can change it value to some default value on specific device. Each item in Settings.bundle is paired with key in NSUserDefaults so you can just set values in NSUserDefaults and the settings application will automatically reflect this. It will be saved elsewhere, though. You can just read it back the same way as you would do with the settings bundle, also through NSUserDefaults.
You can find code example in this answer https://stackoverflow.com/a/32648047/5285151
One more interesting option is to use https://github.com/futuretap/InAppSettingsKit which add same with native settings interface in to the app. And this internal settings synched with device settings but you have more control on it.
I am building an universal Xamarin application for iOS. I am working on the launch screen, and trying to use size classes to modify the layout for iPhone and iPad devices. The positioning works correctly, but when I try to set the image assets things go wrong.
I am trying to use the size class feature on the XCAssets file within Xcode to set the correct image I want for the different screen sizes. I have an image set for [any, any] ([,]) for the iPhone, and then I have one set for the [regular, regular] ([+, +]) for the iPad.
In Xcode's interface builder I can see the correct image in my launch xib file when switching between the [any, any] and [regular, regular] size classes. However, when I run this in my iPad simulator I do not see any images at all. Note that when I run the app in my iPhone simulator the [any, any] images are picked up correctly. It's only when running on my iPad simulator things go wrong.
I have resorted to using Xcode's tools as I cannot find a way within Xamarin to get images within a single image set for different size classes. I believe the issue I'm running into must be an issue within Xamarin not respecting the properties set in Xcode.
My question is has anyone been able to get this to work on Xamarin, and if so how?
Thanks!
Ok, so I found the solution. It appears to in fact be a bug within Xamarin and has todo with Xamarin not always updating the XIB files correctly.
Firstly, do not use the size class options inside of the XCAsset file within Xcode. Simply use the Xamarin version of the tool, and set the iPhone and iPad variations of the image set. I used the naming scheme [image_name][#2x|3x].[ext] for iPhone graphics and the scheme [image_name]~ipad[#2x|3x].[ext] for the iPad variants. However, keep in mind that according to the Apple documentation when you use size classes the ~ipad suffix is ignored. I simply use this suffix to make the file names unique between iPhone and iPad.
Second, go ahead and use size classes as you wish, but do not worry about changing the graphic name, and do not worry about the fact that you will not see an image preview when in the [regular, regular] class.
Third, before running the app use the Xamarin clean command at least once, but sometimes it takes a couple of attempts to fully clean the solution.
After theses steps the image assets worked for me for the iPad via [regular, regular] size class. I know it seems hacky, and may not be the "Xamarin" or "Apple" way of doing things, but it works.
Hope this helps someone else not spend two hours of their life dealing with Xamarin's short comings :)
I have completed an iPad app which only available on iPad iTune store.
But client wants to have different design but similar functionality application for iPhone as well. Some of new feature must be added to iPhone version. I can use most of the functionalities in iPad version and have a new project and build iPhone from scratch!
My requirements will be change during time. New requirements could be for both or either of them. Therefore, I need to add new features in both applications time to time and maintain both applications as well. This app is pretty much complex with more than 150 classes. I need some advice to know is it better to have only one application to works on both devices or it is better practice to have separate project for each iPhone and iPad?
EDIT
I want to use split view controller and vertical menu bar in iPad and side menu and horizontal menu bar in iPhone.
if you want to have two separate iPhone/iPad apps on the store, just make two targets of your application. This will mean you'll probably will use two different storyboards, but that's up to you. Go to your project settings and make two separate targets - one for iPad, one for iPhone. Edit the target general settings where one should only deploy for iPad while the other for iPhone. Posted some pictures below:
You'll want to also go to Manage Schemes, remove the current schemes you have and add the targets you just made. Then set these macros in your iPhone build so you can just edit one code base without needing to edit both the phone and tablet code -
Some example Code:
// Just for Phone Target
#ifdef PHONE
- (void)somePhoneMethod;
#endif
// For both phone and tablet device
- (void)aMethod;
I'd like to add to what everyone has said and if there isn't too much difference just make a universal app.
Use Auto layout and maintain in a single storyboard.
If you know about classes ,Autolayout Strong then my preference is
AutoLayout.
It will reduce your time and easiest handling.
this is Classes here if you like to do vertical layout only for ipad means ,you need to select like this
like this you can choose only for ipad,iphones,portrait,landscape like this :),Its upto your decision.
If UI is same for both so its better to use existing just check in classes for iPad and iPhone.
I have searching questions for my query and I got similar questions, but with older versions of Xcode.
Is there any new things available in latest version of Xcode that can make it easy to make iPhone developed project to Universal ?
Second thing, I have used storyboard, will I have to make separate storyboard file for iPad version ? I have used Autolayout, so will I have to forget about care for frames of views in case of iPad ?
Better, someone give me steps to the migration.
First of all if you want to use separate design for iPad and iPhone, in that case you need to create separate storyboards for iPhone and iPad.
Well If you want to use same design for both devices then you can skip step (2), and in step(3) you need to mention same storyboard name the one you used for iPhone.
I assume you are using different design for both devices, so steps are following.
1) Make your application universal by selecting universal in Devices under Deployment Info.
2) Add new storyboard for iPad by pressing following combination of keys.
Command + N
3) Add name of storyboard for iPad in Info.plist
click "+" button and add following
key :Main storyboard file base name (iPad) Type: String Value: iPad Storyboard Name
After all above steps your are done with basic steps needed to perform for converting app into universal app.
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 ......