Universal apps are not working right. Why? - iphone

Which part of the app is it that "triggers" the iPad app as it's own app as opposed to running the iPhone version in a universal binary?
What do I need to change to make my app Universal, after clicking "Upgrade current Target for iPad"? My app runs on outside of the simulator, but my images are too small and my text is out of place. What am I missing here?
To the opposite end, how do I force my Universal app to run as an iPhone app inside the simulator on the iPad? (When changing "Target Device Family", it will run the iPad version of the app in the simulator, but not the iPhone version.)
EDIT:
It seems to me that these questions kind of complement each other. While I suspect it's the same mechanism at work in both situations, I'm not sure what it is, or how it works.

There are keys in the info.plist file put there by the Targeted Device Family setting. The iPad looks for those plist keys to determine whether to launch as a Universal app or in iPhone emulation mode, and which idiom's xib files to use for app launch.
Added:
If you don't have, and specify in the plist, a .xib file suitable for the iPad idiom, then one with the wrong UIWindow frame is used, which ends up in the upper left corner.

You need to re-code the app for the iPad to lay out your text and images how you want them when it is running on an iPad.
To make it run as an iPhone app you stop it being Universal.

The build setting is called Target Device Family
That's where it starts.
If you wrote a universal app and you want to force the iPhone mode on the iPad you switch Target Device Family to iPhone only and it will ignore everything else.

Related

convert an ipad app to iphone app with custom views

This might be a repeat question.But i have a problem. I have an iPad app functional. The app is built in iOS 6. When i started building it i chose iPad as targeted device NOT universal. Now my client has asked for an iPhone version of it.In my iPad app i keep adding custom views as the client clicks "Add More".I add a custom view which is bunch of textfields, buttons etc.So i copied my iPad app and changed the Targeted device family to iPhone once and also Universal next time and tested it. So when i launch the app in iPhone configuration (keeping the targeted device family as Universal) my view controller stays like that on iPad. I cannot scroll the app also(not up/down..nor sideways). Is this the correct way to convert iPad app to iPhone app . Also everything is still with scale to iPad. Should i start a new project and start everything from scratch.Set the storyboard to fit according to iPhone configuration? In my research people said just change the targeted device family to Universal. But it doesn't work. Please let me know if you need more information. Thanks.
It is possible to convert the current project you have to an app that can be used universally, but it would take more time than simply just creating a new project that allows universal usage, and adding in the files of which you used for your iPad project.
Hint: You can use more than one storyboard when the project was created universally. It will automatically set this up for you.
I would also advise that you separate your files into what works universally, and what is specific for the iPhone or the iPad.
Happy Coding!
After many search i found that it possible to have an application for both Iphone and ipad devices.but in your code you should define unique ui for each device(two xib file).

App targeted for both iPad and iPhone; removing iPad component pre-release

I'm about to release an app that I have been working on for quite some time and is has currently been built to target both iPhone and iPad. The app has both iPhone and iPad storyboards and various device specific code and views. I now wish to remove the iPad references and release the app targeted for iPhone only.
Can a project be changed in this way without too much difficulty and what are the potential complications that may arise?
You should be able to change the device target in Xcode to just iPhone, then verify the build runs in the iPhone simulator window on the iPad. You can also check the bundle plist to verify that UIDeviceTarget contains only 1, not 1 and 2.
If you want to remove the iPad resources, click on your storyboard (or other files), check the properties pane, and uncheck the target. This will stop the file from being copied into the app bundle.
In this image you can see Devices is selected for iPhone only. You can change it from here.

Testing universal app on iphone only

I am developing a universal ios app and the iphone version is nearly done and about 50% of the ipad. However I need to get started testing the iphone version. Therefore I changed the project only to be a iphone target. However when the app is on the ipad, the nib files for the ipad version is loaded in the iphone simulator. Therefore you only see a fraction of the ipad screen in the iphone simulator. One solution is to remove the references to the ipad nib files, however I would like to avoid this approach.
Anyone one with suggestions?
Regards
EDIT: The problem is if I want people to be able to test the iphone version on a ipad(some people only have an ipad not an iphone). When running the iphone simulator on the ipad, it would load the wrong nibfiles. Those intended for the actual ipad and not the iphone.
You don't want to "change the project only to be a iphone target". Change it back and just build and run on the device (iphone or ipad depending upon which one you have plugged in).
Btw, in future I STRONGLY recommend that you test early and test often - e.g. test on devices every day.
Okay, it ended up with the solution I did not want to do :) I removed the nib files intended for the ipad and it removed the issue. After the test I will have to add the ipad nib files to continue working.

Downgrading iPad app to iPhone app

We can upgrade an iPhone project to iPad project as mentioned in the link:
http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iphone_development/120-Building_and_Running_Applications/building_and_running_applications.html
But, I am having an project that is created for iPad. Now, I want to create another target for iPhone (supporting OS same as iPad). How do I do this?
Thanks and Regards,
Deepa
You probably do not want to create a new target for iPhone. What you want is to have a single target that creates a universal application that runs on both iPad and iPhone/iPod touch.
First go to the project settings and change the setting for "Target Device Family" from "iPad" to "iPhone/iPad".
Secondly you will also need two MainMenu.nibs, one for iPad and one for iPhone. You do this in the Info.plist for your target. The key NSMainNibFile should name the nib for iPHone, add a key named NSMainNibFile~iPad to name the nib for iPad.
Now the app is ready to run on both devices, (until you try to use UIPopoverController or other iPad specific class on the phone). Rest of the work is just to make it pleasant, one view at the time.
Use the run-time check [UIDevice currentDevice].userInterfaceIdiom to check at run-time what kind of device you are running. To choose different nibs to load, and other user experience differences.

iPod Touch 4G thinks it's an iPad

I have a universal app built that runs and works perfectly on an iPad, iPhone 4G, 3GS & 3G, but when run on an iPod Touch 4G it won't run properly.
I don't have a iPod Touch to test, but I have been told by a beta tester that it installs on the device fine, but when run it shows the Default.png from the iPad version of the app squashed into the screen when launched, then just goes black from there. When the app is force quit (using the app switcher) and re-launched it does the same thing again.
I have double checked that the Targeted Device Family is iPhone/iPad and done a clean build etc. but still no dice.
So after some trial and error I worked out what the problem was (actually two separate but related problems):
In my info.plist I was using two keys to assign the different MainWindow files:
Main nib file base name (iPad)
and
Main nib file base name (iPhone)
I mistakenly thought the second key would apply to the iPod Touch also as there is no Main nib file base name (iPodTouch) key. Turns out this is wrong and the iPod Touch actually looks for the Main nib file base name key. So now I have it setup like this:
..and it's working fine in 3.1.3 & 4.2. (Note that application:didFinishLaunchingWithOptions is not called if the device can't find a MainWindow to use, that's how I worked out the problem).
I suspect the same will apply to the Launch image (iPad), Launch image (iPhone) and Launch image keys, which would explain why the iPod Touch is using the iPad launch image but haven't been able to try it yet.
Make sure the Default.pngs are correctly named:
Default.png (Default)
Default~iphone.png (iPhone or iPod touch)
Default~ipad.png (iPad)
For the iPad resources you can also specify certain default PNGs for each orientation.
There's currently a jailbreak technique that uses some of the iPad firmware to install on an iPhone or iPod Touch. In theory it shouldn't affect anything, but I've never done it myself so I can't vouch for that. You might ask if this tester is on a jailbroken device, and if so try on a non-jailbroken device.
I am not sure it will work, but it may help you.
Make sure that, in the InterfaceBuilder, the attribute(visibleAtLaunch) in main window is checked.
Some times if it doesn't checked then it will show black screen.