IOS : firing multiple segues from a prototype cell in storyboards

╄→гoц情女王★ 提交于 2019-12-04 23:37:18

问题


Is there a way to connect a prototype cell to different scenes and on the didSelectRowAtIndexPath method call the [self performSegueWithIdentifier:@"NAMEOFTHESEGUE" sender:self] ? I can't seem to drag multiple segues from the prototype cell to different scenes... I know it is possible with static cells because you can draw a segue from each cell to the scene but what if i'm using prototype cells?

I'm currently trying to implement this using the SWRevealViewController (https://github.com/John-Lluch/SWRevealViewController) plugin. In the storyboard example project he's using a table with 3 static cells and connecting each cell to a different scene. But in my case static cells are not an option so if anyone knows the answer that would be great.

Oh and also embedding the "side panel view controller" which is a UIViewController inside a navigation controller so i can connect the navigation controller to different scenes is not an option because in that case the new scene opens inside the slide panel ...

Please take into consideration that i'm still a rookie in IOS programming. Appreciate your time!

EDIT + solution : I had tried connecting the segues from the view controller to the scenes but it kept giving and exception "NSInvalidArgumentException - receiver has no segue with identifier..." The solution was in Xcode to go to "Product" then choose "Clean" : https://stackoverflow.com/a/14089463/1185133


回答1:


Yes, the only thing is that you don't have to connect your prototype cell to multiple destinations, the origin of the multiple segue must be the view controller:

1 - create the segue from your Table View Controller (not the cell) to the destination VC and give to each segue an unique name.

2 - override didSelectRowAtIndexPath: and call [self performSegueWithIdentifier:@"NAMEOFTHESEGUE" sender:self]

That's all :-)




回答2:


If you have you have put a table view within a View Controller, drag the segues from the Controller and not the cell, just as LombaX has explained above



来源:https://stackoverflow.com/questions/17261048/ios-firing-multiple-segues-from-a-prototype-cell-in-storyboards

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!