Reputation: 1492
I am trying to set image for every array in the UITabelView. How can I set image for every array from the photo library? So I can view it in the cell of the UITableView.
I hope this help this is my simple code Download
Thanks from now.
Upvotes: 0
Views: 97
Reputation: 7668
You can do something like this:
NSArray *photos = [[NSArray arrayWithObjects:
[UIImage imageNamed:@"1.png"],
[UIImage imageNamed:@"2.png"],
[UIImage imageNamed:@"3.png"],
[UIImage imageNamed:@"4.png"],
nil] retain]; // Arrange images in the same order your table data is arranged.
Now, in cellForRowAtIndexPath:
method:
cell.imageView.image = [photos objectAtIndex:indexPath.row];
Upvotes: 1
Reputation: 130193
First of all, do you mean for every image? You would do this with one array, populated with images.
You would do this in your table views cellForRowAtIndexPath
method, by telling the table view its cells image property will be filled with the object in the array at the index of the cell, e.g:
cell.imageView.image = [UIImage imageNamed:[myArray objectAtIndex:indexPath.row]];
Upvotes: 0