Questions tagged [imagenamed]

imageNamed: is a method of the UIImage class in iOS. It is a convenience method for loading images without specifying any path information and storing them in a cache.

Explanation from the Apple documentation:

imageNamed: Returns the image object associated with the specified filename.

+ (UIImage *)imageNamed:(NSString *)name

Parameters

name

The name of the file. If this is the first time the image is being loaded, the method looks for an image with the specified name in the application’s main bundle.

Return Value

The image object for the specified file, or nil if the method could not find the specified image.

Discussion

This method looks in the system caches for an image object with the specified name and returns that object if it exists. If a matching image object is not already in the cache, this method loads the image data from the specified file, caches it, and then returns the resulting object.

On a device running iOS 4 or later, the behavior is identical if the device’s screen has a scale of 1.0. If the screen has a scale of 2.0, this method first searches for an image file with the same filename with an @2x suffix appended to it. For example, if the file’s name is button, it first searches for button@2x. If it finds a 2x, it loads that image and sets the scale property of the returned UIImage object to 2.0. Otherwise, it loads the unmodified filename and sets the scale property to 1.0. See iOS App Programming Guide for more information on supporting images with different scale factors.

Special Considerations

On iOS 4 and later, if the file is in PNG format, it is not necessary to specify the .PNG filename extension. Prior to iOS 4, you must specify the filename extension.

Availability

Available in iOS 2.0 and later.

52 questions
0
votes
1 answer

UIImage imagenamed: to CIImage inconsistent results

I am having trouble with the following code; //get a CIImage UIImage *origImage = [UIImage imageNamed:imageName]; CIImage *inputImage = [[CIImage alloc] initWithImage:origImage]; NSLog(@"the inputImage is %@", imageName); imageName is an NSString…
0
votes
1 answer

CoreGraphics: Mass image partition

I have to part 50 square images (600px x 600px) into 9 equal-size (200x200) square parts. To get each part i use method: -(UIImage *)getSubImageFrom:(UIImage *)img WithRect:(CGRect)rect { UIGraphicsBeginImageContext(rect.size); CGContextRef context…
levabul
  • 1
  • 1
0
votes
2 answers

iOS 6.1 XCode 4.6 - imageNamed never return @2x version

Both files "flipImage.png" and "flipImage@2x.png" are in project. In -[FlipsideViewController viewDidLoad] I have the following code. The sanity check (thanks to other stackoverflowers) correctly reports retina or no. But in either case, the image…
Andrew Duncan
  • 3,553
  • 4
  • 28
  • 55
0
votes
1 answer

How to cache images when using imageWithData to make a UIImage

I'm downloading and saving some images from the web into my app's private storage to be displayed in tableview cells. I have it working, but unfortunately unless I'm using : [UIImage imageNamed: @"filename"]; I don't get the built-in cache, and…
jfisk
  • 6,125
  • 20
  • 77
  • 113
0
votes
1 answer

How can I get the list of PNG names that are in my supporting files?

I've dragged and dropped about 30 images (and will be adding more in the near future) into my Xcode project in "Supporting Files" and I want to be able to programmatically get each name that have the extension ".PNG". Is that even possible? Any help…
-1
votes
1 answer

UIImage imageNamed returns nil except for the first image

I'm loading images from my app's image.xcassets using [UIImage imageNamed:@"filename"] method and only the first image is loading correctly but then the rest of the images returns nil and crashes the app. Below is my code: [self.imagePicker…
Ali
  • 4,205
  • 4
  • 25
  • 40
-1
votes
2 answers

Weird Xcode 6 Beta 4 [UIImage imageNamed:] behavior

Historically I've successfully used the == comparator when comparing an image in an imageView to some predefined image using [UIImage imageNamed:]. This is because I receive the same object when calling [UIImage imageNamed:] repeatedly with the same…
Mike
  • 9,765
  • 5
  • 34
  • 59
1 2 3
4