0

I have a standard UITableView of items. Tapping a row will bring a DetailsViewController with details about the selected item and the possibility to use it through a UIButton.

I have implemented the (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath method made available from iOS 8 and I defined two actions:

  1. The standard deletion of the item (pretty simple stuff).
  2. The possibility to use the item like above. I basically want this action behavior to be the same of the IBAction related to the button in the DetailsViewController.

I thought about presenting this view controller automatically and making an automatic tapping of the button without using interaction, but this could be a bit confusing for the user according to me. So I would prefer to call the IBAction method directly from the table view controller. Is it possible and how can I achieve this result?

I can provide the source code if this could help you to help me.

Dree
  • 702
  • 9
  • 29

1 Answers1

0

What you need to do is take the "use this thing" action out of your ViewController, and put it in the Model object for "thing."

Then, when you want to use your "thing" from the tableView or the DetailsViewController, you can call this function directly on the associated model object, and allow your two (possibly more) different user interfaces to perform the "use that thing" functionality appropriately based on their own UI needs.

72A12F4E
  • 1,744
  • 1
  • 14
  • 28