iOS:从情节提要中的原型单元触发多个场景 [英] IOS : firing multiple segues from a prototype cell in storyboards

查看:213
本文介绍了iOS:从情节提要中的原型单元触发多个场景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将原型单元连接到不同的场景,并在didSelectRowAtIndexPath方法上调用[self performSegueWithIdentifier:@"NAMEOFTHESEGUE" sender:self]? 我似乎无法将多个序列从原型单元拖到不同的场景...我知道静态单元格是可能的,因为您可以从每个单元绘制一个序列到场景,但是如果我使用原型单元呢? /p>

我目前正在尝试使用SWRevealViewController( https://github.com/John -Lluch/SWRevealViewController )插件. 在情节提要示例项目中,他正在使用带有3个静态单元格的表格,并将每个单元格连接到不同的场景.但就我而言,静态单元格不是一种选择,因此,如果有人知道答案的话,那就太好了.

哦,还要在导航控制器中嵌入UIViewController的侧面板视图控制器",这样我就无法将导航控制器连接到不同的场景,因为在这种情况下,新场景会在滑动面板内打开..

请考虑到我仍然是IOS编程的新手. 感谢您的时间!

编辑+解决方案:我曾尝试将视图控制器中的segue连接到场景,但它始终给出并显示异常"NSInvalidArgumentException-接收者没有标识符的segue ...". Xcode转到产品",然后选择清洁": https://stackoverflow.com/a/14089463/1185133

解决方案

是的,唯一的事情是您不必将原型单元连接到多个目的地,多重选择的来源必须是视图控制器:

1-创建从表视图控制器(而不是单元格)到目标VC的序列,并为每个序列指定唯一的名称.

2-覆盖didSelectRowAtIndexPath:并调用[self performSegueWithIdentifier:@"NAMEOFTHESEGUE" sender:self]

仅此而已:-)

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

解决方案

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 :-)

这篇关于iOS:从情节提要中的原型单元触发多个场景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆