Tuesday, April 23, 2013

UIImage imageWithData example ios


imageWithData:

Creates and returns an image object that uses the specified image data.
+ (UIImage *)imageWithData:(NSData *)data
Parameters
data
The image data. This can be data from a file or data you create programmatically.
Return Value of [UIImage imageWithData]
A new image object for the specified data, or nil if the method could not initialize the image from the specified data.
Discussion of [UIImage imageWithData]
This method does not cache the image object.
Example of [UIImage imageWithData]

[UIImage imageNamed:fullFileName]
or:
NSString *fileLocation = [[NSBundle mainBundle] pathForResource:fileName ofType:extension];
NSData *imageData = [NSData dataWithContentsOfFile:fileLocation];

[UIImage imageWithData:imageData];