What name should i give for a ipad background image - ios

Im creating a universal app. in my login page i am having a background image i named it as LoginBG#2x and LoginBG#3x for iphone-4,5 and iphone-6 respectively. So, what name should i give for the ipad version images so that iOS will automatically pick them up when my app is viewed in iPad

Use Image Asset Catalogs instead.
It manages image according to device.
You can drag and drop images in respective position -
For more information read - Asset Catalogs

You can give the name as :
file~ipad.png
file#2x~ipad.png
Or batter you can use the assets catalog

Yo can give name like easily you can remember.
like
abc.png
abc_ipad.png

Related

Image suggestions are not working Xcode 10

I am trying to set image to UIImageView. Its working well in older version.
In Xcode 9.4.1
But in Xcode 10
When I am trying to type name of image, image suggestion is not showing.
Even "Image Literal" is not working. Double clicking on above icon also not working.
Is there any setting in Xcode preferences?
How to enable image suggestion like before?
In Xcode 10 and Swift 4.2, only the code completion function (or auto-complete) of the Xcode IDE has been discontinued for the old way. Here is the new way:
Just type image literal and it will complete with default icon.
Double click on this icon and it will open the media library right side of it.
Just choose your image and it work like before!
Hope I am able to help you!
https://download.developer.apple.com/Developer_Tools/Xcode_10_beta_3/Release_Notes_for_Xcode_10_beta_3.pdf
Code Completion for Swift image literals has been removed in Xcode 10. (38087260)
There seem to be some real issues with how Xcode 10 handles image literals, especially when the name you provide your assets doesn't align with the filename of those assets.
The following are the steps I've found will restore image literal previews.
Add an image via the media library picker.
If you have multiple resolutions for your image (e.g. #1x, #2x, #3x), Xcode will inconveniently drop them all into your code and throw an error to let you know you've done something naughty.
Delete two of the faulty image previews, if necessary. You may be left with a default image icon instead of a preview of your actual image.
Comment out the lines on which you're setting the image. You'll see the image literal references the filename of your asset rather than the name you've provided in the asset catalog.
If you've renamed your assets after adding them to your asset catalog, this seems to sometimes prevent Xcode from reading the asset appropriately.
Change the filenames to the appropriate asset names.
You can find the asset names in your asset catalog.
Uncomment the code and, if the default image icon is still visible, double click on the image icon. It should then display a preview of your actual asset.
You may also need to clean and rebuild your project.
use command + shift + M to popup the Media Library then Simply Drag and Drop into your Code
OR

How To Load The Image Set(The Bundle) From Images.xcasset in iOS

When I am developing apps in iOS before, I always put the image sources of the app at the root directory of the project, and then I will load them using [UIImage imageNamed:#"image.png"]. I did't even include various sizes and resolutions such as image#2x or image#3x. But I am afraid this is not a good practice, because I cannot deal with different screen resolutions.
Now, I want to make use of the Images.xcasset to store all my image sources so that I will be able to load just the bundle name, and hoping that the system will pick the image with the right resolution automatically. Therefore, I made a test and place my image set under Images.xcasset and named it as images, and then in my UIViewController.m I am trying to load the image by calling [UIImage imageName:images]. As a result, it didn't work. So I searched for an answer and found out that I should call [UIImage imageName:#"images60x60#2x.png"] in order to load the the 60pt #2x image.
But I think this still did not solve my problem, because I am still choosing which image to load. Is there a way to load the entire image set or load the image according to the resolution of the screen?
Please help. Many Thanks.
EDIT: Added Screen Shots
I use AppIcon as a test
As you said at last that you are using AppIcon as a test. Please don't AppIcon it is made for internal use. try to create you own imageSet and use that. It should work.
Two things :
As said Ankit, do not use App Icon, use your own set
do not use a file suffix. Just reference [UIImage imageName:#"MyImage"] (not [UIImage imageName:#"MyImage.png"])

Apple watch not showing any images

we are having problems with image not showing up on the apple watch, we tried the following :
Our image is located in the apple watchkit extension, and we tried to put it in the cache:
let img = UIImage(named:"slider_r.png")
WKInterfaceDevice().addCachedImage(img!, name:"slider_r.png")
It crashed immediately...
Then we tried to add the image directly on the apple watchkit app: no assets.
No image loaded up...
Then we tried putting it in an image.assets didn't work either...
We are currently out of ideas...
Thanks !
Alright, I've been working with WatchKit for about a month now - here's what I know:
Placing your image into the Watch App's Assets Catalog will add it to the Watch's bundle. This will be immediately available for use using UIImage's .setImageNamed("name").
Placing your image into the Watch Extension's Assets Catalog will add it to the extension's bundle, residing on the phone. Now, to get that to the watch you have to first grab a reference to the image from the extension, then add it to the device's cache, using WKInterfaceDevice().addCachedImage(image, name:).
Check out the Apple documentation for providing images to the Watch here. Here's the documentation for setImage(_ image: UIImage?):
This method changes the image being displayed. Use this method to send images from your WatchKit extension to the WatchKit app. The image interface object is resized to accommodate the size of the newly specified image. If the image itself is too large for the device’s screen, the image is clipped.
This is not what you want. You want to explicitly add the image to the cache so you can use it later. If you use setImage as described above, it will transfer the image from the phone to the watch every time you call it, which is not ideal if you're using the same image in multiple locations or you're using it very frequently. You have to be careful in choosing exactly which images you want to cache on the watch.
Using what we now know:
var img: UIImage = UIImage(named: "slider_r") // grabs the image from extension's bundle
WKInterfaceDevice().addCachedImage(img!, named: "slider_r") // adds to the Watch cache
myImageOutlet.setImageNamed("slider_r") // grabs the image from the Watch cache
Ensure that the asset catalog is included in the extension's target so that the images are correctly placed in the bundle at runtime.
You do not need to include the extension (e.g. ".png") in the image's name.

Naming Convention For Images in XCode 5

i am using XCode 5 when i am naming the images like that :
fbicon~ipad.png
fbicon~ipad#2x.png
Xib is getting the image
but when i am using this Convention
although tha naming convention is
fbicon~ipad.png
fbicon#2x~ipad.png
xib is not picking the images in that case.
Dont Know Why?
Migrate to use the assets catalogue. You just drag your images into the image wells and interface builder picks them up.
If the catalogue doesn't show the iPad iphone specific wells, open up the properties right side bar and tick the appropriate boxes.
assets catalogue
This is happening since you are using XIB.
When used with XIB, for images to be used on iPhone one must use the convention "image~iphone" and for iPad you have to use "image~ipad". #2x is automatically appended based on which version (retina/non-retina) of the image is needed. That's why the first convention works for you.
In case of getting images from the code, e.g. if you have following versions of the "image"-
image~iphone.png
image~ipad.png
image#2x~iphone.png
image#2x~ipad.png
You just call-
[UIImage imageNamed:#"image"]
In this case, the second convention that you mentioned works- as detailed in the Apple doc-
https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/LoadingResources/Introduction/Introduction.html
So, nothing really wrong here as I see. For XIBs, the first convention is correct. For using with code, second convention is correct.

Image loading into UIView

I'm loading an image into my UIView background as a background color from a file stored in my xcode project. It works fine on the iPhone simulator but when I compile on my iPhone, the image isn't there in the background, which is obviously due to the fact that the image isn't stored as a file on phone. Is there a way to hard code an image so it's transported to different devices, forgoing the need to have an image file present?
When dragging a image(or any other reseources), be sure to check this option: Copy items into destination group's folder. In this way, your image will be store in the app bundle, instead to just reference from some path inside your pc.
Here's of this checkbox:
Have you tried
adding the image to the bundle in the copy files build phase?
This will put the image into your app so it will always be there.
Image load important point:
1.Make sure your image below your project document, the true path or relative path.
2.Image name differentiate uppercase and lowercase on the iphone but not use the iphone simulator.
3.Use Xcode shotcuts 'command+shift+K' to clear your project then run again, judge for if the image cached or not.
Run run run!
Happened to me once as well. Remember that if you're using [UIImage imageNamed:#"imageName"];, then with the iOS simulator, you don't need the letters to be in the right case. If your image is named "IMAge.png", then the simulator would find it with the parameter "image.png", but the device wouldn't. So make sure you've got the correct name, the device is case-sensitive.

Resources