Tuesday, November 4, 2008

iPhone SDK : Images in TableView using Objective-C

This simple code will display an image on the left side of cell using Objective-C.


First create a string that contains source information of image file like “Image Name” and “Image Type”. Then create an Image using this String. Then upload the image to the cell.


NSString *imageSource = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"jpg"];
UIImage *image = [UIImage imageWithContentsOfFile: imageSource];
cell.image = image;


Note : The icon.jpg should be in your “Resources” folder.

No comments: