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.
Related
I have been looking everywhere on here and Google, but I still have this weird issue that I can't figure. I have an app pictures below, with 4 UIButtons that have a background image applied:
When I resize/run on the iPhone 5, the top button resizes in a very strange way:
How do I get all the UIButtons to resize the same way with the iPhone 5? Is it possible? Do I need to use a different method?
I really hope this is not a duplicate, but I am completely stumped. If I change the UIButtons around in other positions along the UIView, a different one will resize, or strange gap spacing will show up.... I don't understand. Thanks for any help!
EDIT: I am using iOS 6 on Xcode 4.5. I am testing on an iPhone 4S and an iPhone 5. I have AutoLayout checked. If I use Pin (just found it) I can get the UIButton to keep its height.
To clarify my question. I want the UIButtons to resize so they occupy the same percentage of the screen.... I want the proportions to be the same, instead of simply adding a bunch of empty space. I hope that make it more clear
One of the features you can use is called AutoLayout. Its provided with Xcode to make it easier adjusting things for the 4 inch screen. You can find a good example here: http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
But as far as I know AutoLayout works only with iOS 6 which makes it "not so useful yet". I have been using a class called UIDevice, source of which can be found here: https://github.com/erica/uidevice-extension and check if the platform type is iPhone 5. I have it set up in a method which setups GUI when the view loads. Example of my implementation:
UIImage *backgroundImage;
if ([[UIDevice currentDevice] platformType] == UIDevice5iPhone)
{
//I have a 4 inch screen present
myButton.frame = CGRectMake(x, y, w, h); //Set the frame as you would like it to look on the iPhone 5
backgroundImage = [[UIImage alloc] initWithCGImage:[UIImage imageNamed:#"main_background-568h#2x"].CGImage scale:2.0 orientation:UIImageOrientationUp];
}
else
{
//I have a 3.5 inch screen present
myButton.frame = CGRectMake(x, y, w, h); //Set the frame as you would like it to look on the iPhone 3, 3gs, 4, 4s...
backgroundImage = [[UIImage imageNamed:#"main_background"] retain];
}
self.view.backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
[backgroundImage release];
Hope it clears a bit.
you should firstly disable the use AutoLayout this option is under the "Show the file inspector"
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.
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
How do I support the taller iPhone 5 screen size?
I am new to iPhone and I have a small doubt. Now the iphone5 screen height is 568 and previous iphone's screen height was 480. How can we implement apps for iphone5.Should we check views or controllers all the time for iphone5 and below versions? If am wrong Please correct me.
Thanks in advance.
here are the points
*if you want to make use of full height of the iPhone5 create splash screen that's exactly 640x1136 pixels in size and name default-568h#2x.png
*if you have problem with rotation check
a)window.rootViewController = firstViewcontroller (dont add view to your window)
b)implement the new rorate delegate function
*Use viewDidLayoutSubviews rather than viewDidLoad to set up widget sizes relative to the window
*You can manually check the screen size and load the right image like this:
UIImage* myImage;
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
if ([UIScreen mainScreen].scale == 2.f && screenHeight == 568.0f) {
myImage = [UIImage imageNamed:#"myImage-568h#2x.png"];
} else {
}
myImage = [UIImage imageNamed:#"myImage.png"];
or use catogary from the following GIT gist
https://gist.github.com/3719620
Just use
CGRectGetHeight([UIScreen mainScreen].applicationFrame)
CGRectGetWidth([UIScreen mainScreen].applicationFrame)
to get screen's height & width.
in your project (in XCode 4.5) goto "Supporting File" group (which is automatically created).
you got to use those Default#2x.png/Default-568h#2x.png files. !!
That is the key change required for the OS to size the window to fill the iPhone 5 display. Redth# has posted a writeup on this and other size-related tweaks you might need to make.
!!
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
I have a custom table cell in an iPhone 3.x app to show basketball player data, including a picture. Here's my code from the table controller:
UIImageView *theImage = (UIImageView *) [cell viewWithTag:0];
theImage.image = [manager getSmallImageForPlayer: data.number];
theImage.frame = CGRectMake(14, 0, 30, 44);
theImage.clipsToBounds = YES;
theImage.contentMode = UIViewContentModeScaleAspectFit;
theImage.autoresizingMask = UIViewAutoresizingFlexibleHeight && UIViewAutoresizingFlexibleWidth;
theImage.autoresizesSubviews = YES;
Here's what it looks like in the iPhone SDK 3.0 simulator:
3.0 simulator screenshot http://img96.imageshack.us/img96/9550/imageintablecell30.png
Here's what it looks like in the iPhone SDK 3.1.3 simulator:
3.1.3 simulator screenshot http://img185.imageshack.us/img185/9269/imageintablecell313.png
So I have two problems:
In both versions, the image view starts at position (0,0) in the table cell, even though I set the frame to start at (14,0).
In the 3.0 simulator (and 3.0 device), the image is not shrunk down correctly, even though I set the image view content mode to "UIViewContentModeScaleAspectFit". But the same code works fine in the 3.1.3 simulator / device.
Who can help me with either of these two problems?
You could try creating your own UIImageView and adding it as a subview to table cell
I found the answer on the Apple forums: Using "0" as the tag number for the image view screwed things up; just changing it to "5" made both problems (image not scaled, wrong position) go away.