The first UIViewController is a group table view. Each tableViewCell has a placeholder image.
When you tap a cell you will push to a new view that has the UIPicker (UIPickerDelegate and DataSource is in this UIViewController). Once the user filters down to the image they want they will tap a button to send them back to the previous View. I want the image they selected to now appear in that UITableViewCell.
There are a few ways to get the data back to the previous view controller (I'll call it viewController 1).
One way would be to:
- Add a property to your viewController2 that will be a reference to viewController1, when you create/show viewController2 from viewController1, be sure and set that property, probably just to "self"
- Add a method in your viewController1, called something like didSelectImage: (UIImage*)theImage. In your picker delegate method in viewController2 when the user picks an image, make a call to [self.viewController1 didSelectImage: theImage ].
- In the didSelectImage: method, you save the image in an array or somewhere that you can reference it by the indexPath of a tablecell. Then, you can call the reloadData method for the table cell.
- In your cellForRowAtIndexpath, you can lookup the new image that you just picked and put it in your cell.
Note: I realize there are some gaps in my little walkthrough. Hopefully, you can fill them in.
Edit:
Another way would be to make use of notifications.
- Setup viewController1 to listen for a specific notification, e.g. IDidSelectAnImageNotification
- Setup view controller2 to post the notification with the name above, and pass the selected along with it. This will happen in your picker delegate method.
- After you have the image in vc1, the rest will happen similar to above with the refresh the table view.
Last edited by smithdale87; 09-14-2011 at 11:52 AM.