Create an event (IBAction) from a cell

After all my searches, I did not find any specific information / questions about this: I want to link an entire cell for viewing the table (for example, if it was a button) IBAction (which, in my case, will execute segue).

The fact is that I, apparently, cannot Ctrl-drag a cell into my code to create an event (since there is no category in the storyboard for my connection inspector). This last moment makes me afraid that this is impossible.

I managed to create a segue, directly from Cell, in a different view, but it runs every time I touch Cell. And I need a condition on this segue, so I have a segue from my Table View (containing the specified cell) in the Target View. Then I created an IBAction that calls segue (Table View to Target View).

How to associate your cell with this Segue?

PS : I can change my question for the code, but I only have IBAction in my TableViewController (declared as a class in my table view in the storyboard), and then Segue, which was created using the Storyboard. My table is static (as of now, it is for testing).

+4
source share
3 answers

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

+1

, segue,

@waki

UIViewController:

From Cell To detail Controller

+1
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
0
source

Source: https://habr.com/ru/post/1533543/


All Articles