Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

veliborsantic74

macrumors newbie
Original poster
Sep 6, 2012
9
0
As title says, how to accomplish it? I have 2 UIImageView on every cell which I want to pass to UIImageViews on another controller after user tap that cell?
 
As title says, how to accomplish it? I have 2 UIImageView on every cell which I want to pass to UIImageViews on another controller after user tap that cell?

You should not use the cells to store the image. You should have a data model that saves the data for every entry in your table.
For non-sectioned table, your data model can be a simple array of NSDictionary objects. Each NSDictionary would contain keys for the different things you need to store for that table entry: Text for your label fields, images for your image views, etc.

When the user taps a cell, the cellForRowAtIndexPath method gets the indexPath of the selected cell. It would use the row to index into your array of dictionaries, fetch the image(s) for that entry in your table, and then pass those to your next view controller.

How you pass data to your next view controller depends on how your app is organized. Are you using storboard and segues? If so, you'd remember the row (or row and section) that the user tapped, then invoke a segue. Then in your prepareForSegue method, you'd use the row or row/section to look up the images and set them as properties in your second view controller.

If you're not using storyboards you'd get a pointer to the other view controller (either by creating it on the fly, or saving it if you make it persist) then set the image properties and display that second view controller. (If you're using a navigation controller you'd push it. If not, you could present the second view controller as a modal.)

Anyway, I'm not going to map out in detail all the steps for all the different ways your app could be structured. Provide more info about how your app works.
 
You should not use the cells to store the image. You should have a data model that saves the data for every entry in your table.
For non-sectioned table, your data model can be a simple array of NSDictionary objects. Each NSDictionary would contain keys for the different things you need to store for that table entry: Text for your label fields, images for your image views, etc.

When the user taps a cell, the cellForRowAtIndexPath method gets the indexPath of the selected cell. It would use the row to index into your array of dictionaries, fetch the image(s) for that entry in your table, and then pass those to your next view controller.

How you pass data to your next view controller depends on how your app is organized. Are you using storboard and segues? If so, you'd remember the row (or row and section) that the user tapped, then invoke a segue. Then in your prepareForSegue method, you'd use the row or row/section to look up the images and set them as properties in your second view controller.

If you're not using storyboards you'd get a pointer to the other view controller (either by creating it on the fly, or saving it if you make it persist) then set the image properties and display that second view controller. (If you're using a navigation controller you'd push it. If not, you could present the second view controller as a modal.)

Anyway, I'm not going to map out in detail all the steps for all the different ways your app could be structured. Provide more info about how your app works.

I would like to use solution by creating pointer for second view controller, but I don't know how to grab images from tapped cell row. Images are added on cell.content.view. So, how to get pointers from these images and simply forward them on corresponding UIImageViews?
 
I would like to use solution by creating pointer for second view controller, but I don't know how to grab images from tapped cell row. Images are added on cell.content.view. So, how to get pointers from these images and simply forward them on corresponding UIImageViews?

Re-read my post. The first sentence tells you not to do that.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.