This question already has answers here:
Images for iphone 5 retina display
(5 answers)
Closed 9 years ago.
So typically on storyboard, you assign an imageview with the image you want (foo.png) and then the phones automatically upsize to the retina version if one is on the iPhone 4 or 4s (foo#2x.png).
The question is, how do you get an image to display properly on a 4'' iPhone 5? It is all out of whack when I try it in the simulator and Apple has yet to address this situation with a simple solution as they did with the Retina display of the iPhone 4's. Any help? Thanks!
iPhone 5 support can be added very simply by adding a default#2x-568.png file to your project. Beyond that, it is only a case of making certain the app scales to a new size correctly. Make sure your views accomodate to the new size either programatically, or by setting springs and struts correctly in your UI archives (XIBs or Storyboards as appropriate). You shouldn't need any new images (*). If you already
support retina devices, then you only need to add the new splash screen as above.
(*) If you do for whatever reason, I'd recommend reading this answer:
ios6 UIImageView - Loading -568h image
Apple doesn't provide a good way of using different images on the iPhone 5, because you aren't supposed to use any!
Related
My iPhone-only Objective-C app (iPad not checked) runs correctly on SE 2nd up to iPhone 12 Pro Max, properly centered, fully functional, but is stretched and clipped on any iPad (in Simulator--I blanked center content below re privacy), and on some I get black screens. Every element is constrained ultimately centered on Superview X and Y centers (nothing absolute); is that the problem? Is there a typical problem that keeps iPhone-only apps from appearing properly on iPads? The app in no way does anything special for iPads. Is there a good tutorial about this subject? Thanks
The answer is simply that constraints sufficient for all iPhones are not necessarily sufficient for iPhone in iPad. Just because the app is sized correctly for all iPhones doesn't mean it's correct for iPhone in iPad. That's what this newbie learned!
I have iPhone app and storyboard is done.
and every view in story board has iPhone size.
Now i tried to set any any size for views but it has problem.
when change size to iPad (any any) , all of objects in views will disappear and then running app , not showing anything in iPad view.
I don't wanna using another storyboard.
Target Device is Universal and i am using Objective C.
Thank you
Help me.
Update:
Resolve the issue with cells not appearing on iPad, needed to add the UICollectionViewDelegateFlowLayout methods for iPad.
Original:
If you get the size classes to regular width and height (iPad size classes), then set the constraints for your objects, I assume they are a width and height of 0, that's why you can't see them.
I think it's better to build constraints for (any, any) and then create specifically for iPhone or iPad if necessary, if you are creating a universal app.
Let if know if you encounter problems, hope this helps, good luck.
For a new project my client wants to cover all iPhone and iPad sizes. For icons and sprites I'm not really gonna change the shapes of the images, but I'm in a bind with assets for my background images.
Looking at http://iosres.com I was wondering if there is some logic to cover both Landscape and Portrait 3:4 and 9:16 in one asset or should I simply make a set of iPhone and iPad and use UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad to figure out what to show before loading my views?
Also I'm wondering what's most effective for all the different device sizes. I know from experience that an iPad 3 wouldn't like to have a background image loaded on 4k resolution and that you want to avoid pixel differences so it won't trigger scaling in UIImageViews. Will iOS automatically figure out that the iPad 3 will use like the #1x variations, whereas the iPad Pro will load the #3x versions?
Yes iOS will automatically figure out which image to load at runtime and load #1x #2x or #3x depending upon the type of device. You don't need to do anything like UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad for each image.
Edit:
You can also add ~ipad suffix in image names so iOS will pick the appropriate background image for iPhones and iPads. i.e. image_name#2x~ipad.png and image_name#2x.png.
I am making an app, and recently, out of the blue there has been a problem.
When I ran my app on my iPhone, (which I have been doing fine for the last few weeks) the images show up at completely different sizes.
For example:
The start button on the Xcode simulator is xScale 2.0f. On the iPhone it shows to be roughly half that size. I keep all the images in a .atlas file, and they are all .png. I am using sprite kit as well, and the iPhone I am using is on iOS 7.
Here is what I'm getting:
Unwanted result (As is on iPhone)
Here is what I would like:
Desired Result (As is on simulator)
This has also happened throughout the app, with other sprite nodes. Does anyone know how I can fix this problem? Thank you in advance, and I would have posted screenshots if it wasn't for the 10 rep limit.
Edit:
I have now got most of the images working, by creating a #2x version of all the images.
But there is still one graphic that is this time TOO LARGE on the iPhone. Thank you for all your help so far, does anyone know how I can make that one image smaller on the iPhone?
Your PNGs need to be labeled with a 2x or 3x. This is Apples way of accounting for the retina screens.
"ImageFileName#2x.png"
for Iphone 4,5,6
"ImageFileName#3x.png"
for Iphone 6 Plus
If you have no extension, Apple will assume it should make your image 2 or 3 times bigger to account for the extra pixels in the retina displays. If you add the #2x or #3x, Apple assumes you provided the image already accounting for the retina pixel count.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Specify images for iPad in Xcode like #2x for iPhone 4
I'm having trouble finding current conclusive information about how to properly use images based on device classes (Apple documentation being like a maze of twisted corridors, all alike). My sense is that this is something that has evolved a bit over time. Suppose I want to support non-retina and retina iphones and ipads with different images.
Here are all the permutations of filenames that I can think of:
image.png
image#2x.png
image~iphone.png
image~ipad.png
image#2x~iphone.png
image#2x~ipad.png
I could do this:
myview.xib
myview~ipad.xib
Suppose I have four devices, iPhone 3GS, iPhone 4, iPad 2, iPad 3 (or 'new iPad' for purists).
Let's talk about how I would set up my xibs (i.e. I add a UIImageView, what do I choose for an image?) to use the appropriate image and how, if I use code, [UIImage imageNamed:#"image"] would behave.
It's my understanding that in code I could fall back on UI_USER_INTERFACE_IDIOM() but I'm not convinced that I need to.
If someone could explain what will and won't work, I know that it'll be a help to me, and I suspect to others. If I've somehow duplicated another SO question I couldn't find, well, we can close this up and link to it. Thanks!
in iphone xib you have to use image~iphone. on ipad xib you have to use image~ipad. #2x is automatic selected when file is needed.