I have a table view, and I am adding four UIImageView
s to a row, so in total I have five rows and twenty image views. I am inserting images one by one into the cell. The second row will only start to fill once all four image views are filled.
I need some logic for this. I mean, how can I check which place is next to be filled in the table view and at which event? How can I add images one by one to the UIImageView
s? Also, initially only two rows will be shown. After filling these two rows, when images begin to enter into the third row, I need to show an icon adjacent to the last row that is on the screen, to tell the user that there is more data below. Also, is there any event to detect which row is currently the last row on screen?
Also is there any way to individually select the images from a row?
try this, As there are fix number of images that you want to show in your row i. e. 4 So what you have to do is:- in .h file
in .m file in viewdidload
This code is for 2 rows do the same thing for next three rows. Adjust the coordinates according to your requirement. hope this will save your time.
Run this code:-
.m file code:-
You should keep all of the logic (and data) in your table view controller (
UITableViewController
subclass). I suggest you have a customUITableViewCell
subclass that can hold 4 images (the cell itself should be responsible for the layout), and the table view controller is responsible for setting it up. In-tableView:cellForRowAtIndexPath:
you can look at your collection of images, then just use modular arithmetic to figure out which images should be in the cell for that particular index path.As for individually selecting images, perhaps you could have your cells know their index path (set as a custom property in
-tableView:cellForRowAtIndexPath:
), then each have a delegate method telling your controller that a certain image was pressed (for example,-cellAtIndexPath:didSelectImageAtIndex:
).answer for Also is there any way to individually select the images from a row? : Give image to button and add that button inside row!!