iPhone 4 doesn't load retina images - iphone

I have an app for iPhone that uses some images compatible with retina and non retina devices. When I lunch the app on any iPhone simulator it works perfectly, retina and non retina images are loaded.
The issues appear when I select the app to run on my physical device (iPhone 4). In this case the retina images are not loaded any more and everything seems blurry.
I used "Don't Code Sign" since I don't have a developer account yet. I just wanted to get a feeling of my app, could it be because of this?
Here is a sample project that has the same behaviour on my physical device:
http://db.tt/XL4DPLH8
Solved: retina images were name 2X instead of 2x...also in the project and in the example.app / Thanks for the answer Adam (his answer disappeared)

Check resolution at start up by NSLog and then setting appropriate image...
- (void)viewDidLoad
{
[super viewDidLoad];
// NSLog(#"bound :%f", [[UIScreen mainScreen] bounds].size.height);
NSString* imageName;
if([[UIScreen mainScreen]bounds].size.height == 568)
{
imageName= #"568h#2x.png";
}
else{
imageName= #"bg#2x.png";
}
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:imageName]];
hope help

Related

Xcode: Background image resized in app

I'm using a 640x1136 image as background for my app but the image appears zoomed in. The same image, as splash screen, is displayed correctly. I followed the directions found here.
Two pics,
the original image:
Screen capture, simulator iPhone 6.1, and the look is the same on my iPhone 5
The code I am using is the following:
CGRect screenSize = [[UIScreen mainScreen]bounds];
if (screenSize.size.height == 568.0f) {
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"Default-568h#2x"]];
}else {
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"Default#2x"]];
}
You have tabbar at bottom of application. So, you need to use different image for Splash screen and background screen for Inicio tab.
You are using ratina images(Having suffix as #2x) and checking in NonRetina simulator. So select Retina based simulator using iphone simulator property as
Hardware -> Device -> iPhone(Retina 4-inch)
and then run app.
Hope it helps you.

How to migrate apps for iPhone 5 screen resolution?

I have an application in iphone in which i am using most of the static images in the background as an image in the background image it self.Means a single background image including all the staic things.now i want to migrate to iphone 5 also.Now i am using an image of 640*960 as the background image.if i change that to 640*1136 then when it used in 4serieses of iphone the image will shrink i think.Let it i am fixing the frame size by checking the screeen.Can anybody help me how i can resolve this issue?
To know, what kind of image You should use (for iPad 768x1024, for iPhone 320x480, etc..)
You can detect device, and then set corresponding image.
You can distinguish between iPad/Retina/iPhone using this SO article:
Detect retina screen/iPhone 4 in iPhone SDK
You can detect iPhone 5 using example in this SO article:
How to detect iPhone 5 (widescreen devices)?
If you have only portrait supported, You can check using this simple method:
if([[UIScreen mainScreen] bounds].size.height == 480)
{
//iPhone, iPhone retina
}
else if([[UIScreen mainScreen] bounds].size.height == 1024)
{
//iPad, iPad retina
}
else //568 height
{
//iPhone 5
}
And of course - as Valeriy Van mentioned, You need Default-568h#2x.png image added to your bundle.
There is no connection between image resolution and size of UIImageView. Image will be rescaled or positioned inside view bounds depending on contentMode property.
What you need first - add Default-568h#2x.png image of 640x1136 as Launch Image for Retina 4 inch. If springs and struts of your views are set right, everything will work as granted.

Strategy for downloading high resolution images from server for retina display

So with the retina displays on iOS I usually have images with twice the size named #2x per apple's guidelines on how to do retina displays. But this naming convention only works with images in the app's bundle which I can't write to.
What is your strategy for pulling down high resolution images from a server?
Should I always just pull down the high res images (say 120x120 for a normal 60x60 image) and slap it into the uiimageview?
to set retina Image you should
UIImage *image; // from download
image=[UIImage imageWithCGImage:[image CGImage] scale:2.0 orientation:UIImageOrientationUp];
Check first if you have a retina display
if([[UIScreen mainScreen] respondsToSelector:#selector(scale)])
BOOL retina = [[UIScreen mainScreen] scale] == 2.0 ? YES : NO;
if "retine == YES" , fetch the retina image you want

Iphone dev ios not picking up 2x images in ray's application

I have downloaded ray wenderlich's code for apns application from this link
http://www.raywenderlich.com/3525/apple-push-notification-services-tutorial-part-2
now i converted that project of ray's to tab bar application project, now i am having a problem with tab bar image. i added x and 2x resolution images in my images folder of project, and doing this in view will appear
AppDelegate *delegate2 =(AppDelegate *) [[UIApplication sharedApplication] delegate];
for(UIView *view in delegate2.tabBarControler.tabBar.subviews) {
if([view isKindOfClass:[UIImageView class]]) {
[view removeFromSuperview];
}
}
[delegate2.tabBarControler.tabBar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"home.png"]] autorelease] atIndex:0];
the 2x resolution image which is home#2x.png, it is not being picked by ios 5 device (ipod 4) i know that the operating system (ios 5) automatically senses the 2x image and pick it, but in my case its not happening, rather its picking the x resolution image and there is a white line showing under tab bar, i am stuck here , please guide me thanx and regards Saad.
Lets run through some basics to see where something may have gone wrong;
Put the following line in your code, just after that and see what it prints out;
NSLog(#"Image scale : %f",[[UIImage imageNamed:#"home.png"] scale]);
If it prints out 'Image scale : 2.000000', that means the #2x image has been correctly identified and loaded by the app.
Also;
Delete both images, clean the project, add them and try rebuilding
Make sure the case of home.png and home#2x.png match exactly
If you're trying this on a simulator, Reset the simulator and try again.
If you already have a previous build on your device, delete it and try again.

How do I write an iPhone/iPad app to take care of different screen sizes?

With the new iPad (which has a different screen resolution of the iPhone/iPod Touch), how do I set the application to automatically size appropriately to the desired screen size?
Read the iPad Programming Guide in the 3.2 SDK beta documentation. It will tell you everything you need. The NDA means we can't talk about it here publically.
Although the iPad SDK is still under NDA at this time, the iPhone SDK which preceeds it introduced the ability to change the screen size:
- (BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)opts
{
UIScreen *s = [UIScreen mainScreen]; // ask for the main screen
[window setFrame:[s applicationFrame]]; // get the application Frame for the screen
return YES;
}
If you have used NIBs for the UI construction, you need to ensure that they're auto-resizable in order for them to flow properly.
The issue is not in the code. It is in the project conversion from iPhone to iPad: http://www.cocos2d-iphone.org/forum/topic/4108