I am new to iOS . I have created a new group in image.xcasset file. I have imported 100 images to that group for make a small activity view. My problem is how to call the image.xcasset images from my viewcontroller code. I need code for that. Can any one help me?... Thanks for advance.
Asked
Active
Viewed 544 times
1
-
For more information on how to use image assets check [here](http://stackoverflow.com/questions/26020979/xcode-6-xcassets-for-universal-image-support). – Jaideep Nagra Aug 13 '15 at 06:04
-
Can you please share your code? – Bharat Nakum Aug 17 '15 at 11:39
1 Answers
2
Image Assets > New Image set> name it "MyImage"
-- in 1x (MyImage.png)
the image with normal scaling actually you can name it whatever you want but this names it more manageable, same goes for the rest!
-- in 2x (MyImage@2x.png)
-- in 3x (MyImage@3x.png)
Call them directly, If from storyboard under the image property of ImageView write "MyImage", and the image according to the device will get displayed automatically depending on retina, non retina and device scaling factor.
If by code then myDynamicImageView.image = [UIImage imageNamed:@"MyImage"];
Hope this helps

Saheb Roy
- 5,899
- 3
- 23
- 35
-
i put 112 images in 1x,.i need to call one by one in loop i using the following code NSMutableArray *images = [NSMutableArray array]; for (NSInteger i = 1; i <= NUMBER_OF_ANIMATED_LOGO_IMAGES; i++) { NSString *fileName = [NSString stringWithFormat:@"HouseProlog_loader%04ld", (long)i]; [images addObject:[UIImage imageNamed:fileName]]; } // my image name starting with HouseProlog_loader0001 and ending with HouseProlog_loader0112. when i run this code i getting error like "Images.xcassets: None of the input catalogs contained a matching app icon set named "AppIcon" – Roby Aug 13 '15 at 06:07