IOS StoryBoard multiple Segue's from a TableCell

后端 未结 4 1692
眼角桃花
眼角桃花 2020-12-12 15:15

Hi I have a storyboard and am able to show a detail view when clicking on a table cell. I want to add extra functionality so that depending on what cell I click I show a dif

4条回答
  •  Happy的楠姐
    2020-12-12 15:51

    Don't try to create multiple segues from a TableCell to other view controllers, you want to ctrl+drag from the view controller icon below the view controller in the storyboard interface to the viewcontrollers you want to segue to. Then it will allow you to set up multiple segues.

    screenshot showing multiple segues

    and then to actually make the segues work, you need to add identifiers to the segues themselves, which you can do by clicking on them and then giving it a name in the property inspector:

    giving segue an identifier

    then, for the example of TableCells, in your UITableViewDelegate, in

    -tableView:didSelectRowAtIndexPath: 
    

    you can use

    - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender 
    

    to manually start a segue depending on your own logic of what segue should be chosen.

提交回复
热议问题