how to run iPhone classic app in iPhone5 - iphone

I develop application using iOS5.0, now I want to run app in iOS6.0. It's working fine using iPhone classic devices, but not working fine in iPhone5.
Because [[UIScreen mainScreen] bounds] is returning {{0, 0}, {320, 480}} in iPhone5, I wrote code using
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
CGSize result = [[UIScreen mainScreen] bounds].size;
if (result.height == 480)
{
// iPhone Classic
}
else if (result.height == 568)
{
// iPhone 5
}
}
But screen bounds return same frame. How it will change?

Add splash screen for iPhone 5. You can see a warning if you go to Your Target -> General -> Launch Images.

For the application to run in "tall mode", you need to have a Default.png splash screen the correct height for an iPhone 5. This will instruct the application to run in tall mode, meaning you'll get the correct bounds.
Information can be found at the Apple Dev Centre. Basically, you'll need to provide a splash/launch image with a size of 640 x 1136 pixels, and a name of Default-568h#2x.png.
To specify default launch images for iPhone 5 and iPod touch (5th generation) devices, include the modifier string -568h immediately after the portion of the filename. Because these devices have Retina displays, the #2x modifier must always be included with launch images for the devices.
For example, the default launch image name for a device is Default-568h#2x.png. (If your app has the UILaunchImageFile key in its Info.plist file, replace the Default portion of the string with your custom string.).
You can easily add this image via the target settings for the project in Xcode. Simply select your project file, then select the application from the target list. Within General, you'll find settings such as Application Version number, Deployment Target etc... Further down the list you can select your launch images, and there'll be a placeholder for iPhone 5 devices.

Related

Universal app with .#2x only

My universal app has two storyBoards. One for iPhone and one for iPad. A lot of the code has been coded programatically and both storyBoards share the same ViewControllers. An example of how this works in view controller as follows:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){ iPadInUse = YES;}
else { iPadInUse = NO;}
So, if I have a image that needs to be displayed on both devices - I write the following:
if (iPadInUse == YES) { recordViewImage = #"iPadRecordPanel#2x.png"
// x and y positions to adjusted accordingly }
else { recordViewImage = #"recordingPanel#2x.png"
// // x and y positions to adjusted accordingly}
On the simulators everything works fine for all devices (retina /non retina). The only actual device I have is an iPhone 4S (all works fine). Is this ok what I'm doing as do not actually have any non retina images loaded fro non retina devices (all images suffix with #2x.png ??
Will my app get rejected because of this ??
No, this is not ok.
On devices that do not have retinta screen more memory will be used to load the retina images.
You should always provide non retina and retina images and never load #2x images directly. iOS will load the correct image for you.
Your app will not get rejected, and everything will work fine.
But there are two issues:
On non-retina devices, App will load larger images. Which is not required there..so memory utilization will increase there without any outcome.
You don't need to write conditional code for iphone and ipad for setting images.
You can use a tilde while naming the image files:
iPhone:
image#2x~iphone.png (retina only)
image#2x.png (retina only)
image~iphone.png
image.png
iPad:
image#2x~ipad.png (retina only)
image#2x.png (retina only)
image~ipad.png
image.png
It will not display proper image when you will give it name like iPadRecordPanel#2x.png. You can give name iPadRecordPanel.png and it will take 2x image of it from bundle. You can not give suffix with #2x. it will automatically identify proper image and display it.
No your app will not be rejected but you should not do this because not providing non-retina images may decrease performance and image quality on older devices due to the required down-scale operations.
Hope it helps you.

How to simply switch from iphone 4 size to iphone 5 size?

I would like to know how could I make my application enable for iphone 5 standards (especially screen-size).
I currently have an application designed for iPhone 4 so all the views are 460 px height.
Can I do some simple and automamic update to make it for iPhone 5? Without ruining the iPhone 4 style, I would like this app to be avaible on both.
There is not magic code that will make app adjust it self, just the Default-568h#2x.png top tell iOS that you app support the new 4" height.
The most important part is how you have set the Autoresize mask of you views. If then are set to grow (UIViewAutoresizingFlexibleHeight) then they will grow to fill the screen.
Check every view that the alginment of button have the correct Autoresize mask, for example if a button is ment to be at the button of the screen make sure that the Autoresize mask is set to the fix it self to the bottom and nog the default top.
First, see what your app looks like on iPhone 5. This can be done by including a Default-568h#2x.png within your project. This is the launch image for iPhone 5, and indicates to the OS that you support the taller screen size.
If you've programmmed your application well (for example, with decent Autoresize masks), the OS should take care of most of it for you, and it'll look decent already. If you want to use AutoLayout in iOS 6, this will also help for the iPhone 5.
If it does not look that great, then you can do some conditional modifications for iPhone 5 using the macro:
#define IsTallPhone() ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568)
So for example:
if (IsTallPhone()) {
frame = CGRectMake(0,0,200,500); // Use Tall Frame
}
else {
frame = CGRectMake(0,0,200,300); // Use Normal Frame
}
The conditional can be done for anything, for example to load a different .xib file. It entirely up to you.
Open your project in xcode 4.5 and just add a default image of iPhone5 resolution in launch images. all other screens will be stretched to fill the iPhone 5 screen. go to target summary and add retina 4 inch launch image.
But it really depends on the graphics they may appear stretched go for separate xib if required

Screen size of iPhone 5

I'm developing the app to work both on iphone4 and iPhone 5. I'm using the following code to get the screen size
CGRect screenBounds = [[UIScreen mainScreen] bounds];
am using the iPhone 5 simulator but it showing the screen size of iPhone 4.
On the simulator make sure you have set to iPhone (Retina 4-inch).
You can do this by going simulator menu at the top go to Hardware>>Device>>iPhone (Retina 4-inch) that will change the phone simulator to the iPhone 5 version.
If this is set then you may need to add a launch image for the iPhone 5. Default-568h#2x.png if this is missing it will not launch in iPhone (Retina 4-inch).
I have also answer another question here that may help.
When running the simulator, go to Hardware -> Device and make sure that iPhone (Retina 4-inch) is selected.
In fact
[[UIScreen mainScreen] bounds].size.height
returns 568 for iPhone 5. Make sure, you selected "iPhone 4 - (4 inch)" as Device in the Simulator (it's there since Xcode 4.5). There should also be an Default-568h#2x.png file in your project if you created your project using the Xcode assistent.

Is there an image name convention for iPhone 5

I'm using an image that will fill the full view of an iPhone. For iPhone 3GS we name it image.png for iPhone 4 we name it image#2x.png -is there an image name convention for iPhone 5 where it will automatically substitute it, or do I need to manually check which device I'm on?
I've read elsewhere that we keep on using #2x but I don't want my image stretched.
There is no specific image name conventions for iPhone 5 except for the Default-568h#2x.png image.
Your images will not be stretched when you use #2x on the iPhone 5, it is just the layout that will change.
Since there is no specific naming convention for the 4" screen (5th gen iPod touch and iPhone 5), you need to check the screen height yourself and load a different image.
if ([UIScreen mainScreen].bounds.size.height == 568) {
// 4" screen - load appropriate image
} else {
// regular screen - load standard image
}
This will work in portrait orientation.

Image Naming Convention for iPhone 5

what is the Image Naming Convention for iPhone 5 like #2x for retina screens.
It is just the same. The #2x just means it's a retina image.
The only difference is the 568#2x (or whatever it is) for the splash screen but Xcode renames that file for you anyway.
Just keep using #2x.png
till now they have not released any official documentation for the iPhone5 Images.
You can do like this.
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && [[UIScreen mainScreen] bounds].size.height * [UIScreen mainScreen].scale >= 1136)
{
//Write the code here for iPhone5 Image.
}
else
{
//this is for unto 4th gen iPhone
}
There is no specific naming convention for images on iPhone 5.
The Default-568h#2x will be shown on launch of an iPhone 5 or iPod Touch 5G. This will also enable the non-letterbox mode of your app. For your other f.e. background images you have to design flexible if you want to cover both screen resolutions. When you building an iPhone 4s App assure that f.e. a background image can be strechted up to the iPhone 5 size.
it is just the same. The #2x just means it's a retina image.
The only difference is the 568#2x (or whatever it is) for the splash
screen but Xcode renames that file for you anyway.
Just keep using #2x.png
I must add, that if you look at the simulator the pictures maybe stretched! You could fix this by checking the box (if u use storyboard) "auto layout" I have some problems too maybe this is a bug which will be fixed I hope...
and on storyboard or .xib u can change the size of the controller like here: