如何在prepareForSegue之前调用didSelectRowAtIndexPath? [英] How to call didSelectRowAtIndexPath before prepareForSegue?

查看:81
本文介绍了如何在prepareForSegue之前调用didSelectRowAtIndexPath?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作iOS应用程序,这是tableview基础。
这是我想做的事。
Tableview1 - > Tableview2
一旦我选择了一个tableCell,就会显示新的tableView2。
我想在显示新的tableView之前显示单元格。
尽管如此,由于加载了新的tableView数据,hilight非常慢。
我抬头看了这个。 prepareForSegue 的原因是在之前调用didSelectRowAtIndexPath

I'm making iOS app which is tableview base. Here's what I want to do. Tableview1 -> Tableview2 Once I select one of tableCell, new tableView2 is shown. I'd like to hilight the cell before new tableView is shown. Nonetheless, hilight is so slow because of loading new tableView data. I looked up this. The reason why is prepareForSegue is called before didSelectRowAtIndexPath.

那么你能告诉我如何在 prepareForSegue 之前调用 didSelectRowAtIndexPath

Then could you tell me how to call didSelectRowAtIndexPath before prepareForSegue?

或告诉我如何在选择单元格时设置表格单元格。

Or tell me how to set up table cell when cell is selected.

一切顺利。

推荐答案

你正在采用两种不同的方法来实现它。

You are meshing two different ways to do it.

1 - 第一种选择 - 只使用故事板和prepareForSegue:

1 - First Alternative - use only storyboards and prepareForSegue:

将原型单元连接到storyboard中的第二个viewcontroller(连接必须从单元格开始,然后在第二个viewcontroller上结束)。
在这种情况下,您必须使用 prepareForSegue方法而不是didSelectRowAtIndexPath。第二个VC在prepareForSegue之后自动推送。

Connect your prototype cell to the second viewcontroller in storyboard (the connection must start from the cell and end on the second viewcontroller). In this case, you must use only prepareForSegue method and not didSelectRowAtIndexPath. The second VC is pushed automatically after the prepareForSegue.

2 - 第二个替代 - 使用didSelectRowAtIndexPath:

2 - Second Alternative - use didSelectRowAtIndexPath:

你使用didSelectRowAtIndexPath仅当您将segue 从第一个视图控制器(而不是从单元格)连接到第二个视图控制器时。
在didSelectRowAtIndexPath方法结束时,您必须调用performSegue。

You use didSelectRowAtIndexPath only if you connect the segue from the first viewcontroller (and not from the cell) to the second viewcontroller. At the end of didSelectRowAtIndexPath method, you must call performSegue.

这篇关于如何在prepareForSegue之前调用didSelectRowAtIndexPath?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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