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
2
votes
1 answer

Lazy loading images in scrollview seems to increase memory

I am lazy loading images in a scrollview. However as I scroll the content memory allocation increase and it is rather sluggish. Here is my code; - (void)scrollViewSetUp { self.scrollview.delegate = self; …
DevC
  • 6,982
  • 9
  • 45
  • 80
2
votes
1 answer

ImageIO_PNG_DATA keeps on growing after application is moved from background to foreground

I have an application in which i am using lots of images but i have found an abnormal issue with the application memory footprints. I am using imageNamed method to initialise UIImage objects. From the documentation i have read that imageNamed keeps…
2
votes
1 answer

Need a little help in loading image with absolute path

I have 400 images with repeating names, hierarchically divided among folders which i have included in my project, now i want to load images with the absolute path, I tried using imagenamed but instead of images being load, empty box is showed. Now I…
X-Factor
  • 2,067
  • 14
  • 18
1
vote
3 answers

imageNamed is evil - How to use the function

- (UIImage*)thumbnailImage:(NSString*)fileName { UIImage *thumbnail = [thumbnailCache objectForKey:fileName]; if (nil == thumbnail) { NSString *thumbnailFile = [NSString stringWithFormat:@"%@/thumbnails/%@.jpg", [[NSBundle…
nishantcm
  • 935
  • 5
  • 14
  • 28
1
vote
1 answer

setImage - addSubview - release

Here is some code for iPhone: Controller.h: IBOutlet UIImageView *userImage; IBOutlet UIImageView *userImage2; } @property (nonatomic, retain) IBOutlet UIImageView *userImage; @property (nonatomic, retain) IBOutlet UIImageView…
enegene
  • 31
  • 1
1
vote
2 answers

UIImage imageNamed not returning image object in iOS 11

The following code returns an image object from path and works previous to iOS 11: NSString *path = [anotherPath stringByAppendingPathComponent:file]; UIImage *image = [UIImage imageNamed:path]; However in iOS 11, image returns null. Is this an iOS…
Hahnemann
  • 4,378
  • 6
  • 40
  • 64
1
vote
1 answer

UIImage imageNamed returning wrong image

I'm having a weird problem using [UIImage imageNamed:] method to set table view cells' backgrounds. I typically do this for a cell: backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_background.png"]]; For some unknown…
Jukurrpa
  • 4,038
  • 7
  • 43
  • 73
1
vote
0 answers

imageNamed leads to bad fluency in iOS9

Development Environment:iOS9 Xcode7 In tableView,if cell set image with [imageNamed:], it will make bad fps and bad lag phase. So Why ? Just apple changed its underlying mechanism or just iOS9 with bad optimizer ? And now, there are so many…
0x10
  • 21
  • 1
1
vote
1 answer

Getting launch image from XCAssets using imageWithContentsOfFile:

I'm attempting to load images from my LaunchImage image set in a .xcassets file, but I don't want do use imageNamed:, as it wastes memory and the image only needs to be displayed for a couple of seconds during initial launch. I have tried multiple…
rebello95
  • 8,486
  • 5
  • 44
  • 65
1
vote
1 answer

Save image with my own custom image in ios

I want to save an image to camera roll with my own imagename in ios 5.I am using AV Foundation for accessing camera features.Please help me with possible solutions.
1
vote
1 answer

ipad 1 Crash - my app is bad somewhere

I have made an app, but on ipad 1 it crashes in the end part. On ipad-higher it remains working, but still I think I am doing something wrong, I really need to make something working more economically. But what is it? In the end part it all happens.…
Pip
  • 159
  • 2
  • 9
1
vote
3 answers

Override UIImage imageNamed - what are my options?

Basically my code heavily uses [UIImage imageNamed] which by default fetches image from app bundle. Now I want the images to be returned from a directory deep within Documents (or library or whatever) - instead of main bundle. And since there are so…
Nirav Bhatt
  • 6,940
  • 5
  • 45
  • 89
1
vote
1 answer

Issue using GLKTextureLoader and imageNamed: when loading same image multiple times

I get strange behaviour when I use the following code to load an image multiple times: NSDictionary *options = @{GLKTextureLoaderOriginBottomLeft: @YES}; textureInfo = [GLKTextureLoader textureWithCGImage:[UIImage imageNamed:@"name"].CGImage …
Anton Holmberg
  • 1,113
  • 12
  • 15
1
vote
4 answers

Objective C: imageNamed loading non existing image

I use a loop to load images into an NSMutableArray. Each iteration loads an images using the imagedNamed function in UIImage: [UIImage imageNamed:*name*];. However, I wanted to change some of the images. So I removed the images from the project and…
Mark
  • 1,258
  • 13
  • 25
1
vote
1 answer

page-based with storyboard dont dealloc

I am developing a complete application using the template "page-based storyboard". But whenever I turn page, I see thru the instruments that the amount of memory allocated only increase and never decrease, so until a crash occurs. Trying in iPad…