简体   繁体   English

如何从Firebase检索数据到表视图控制器并将其传递给另一个视图控制器

[英]how can I retrieve data from firebase to a table view controller and pass it to another view controller

I retrieved my data using firebase database into a table view cell in a view controller. 我使用firebase数据库将数据检索到视图控制器中的表视图单元中。 I want to forward the data to another view controller. 我想将数据转发到另一个视图控制器。 enter image description here i try by creating variables assigning them to table view cells label but when trying to retrieve the app crashed enter image description here . 我尝试在此处输入图片描述,方法是创建将变量分配给表格视图单元格标签的变量,但是当尝试检索崩溃的应用程序时,请在此处输入图片描述 here are my sample codes enter image description here 这是我的示例代码, 在此处输入图片描述

png png

This function expects an Any as parameter, so in your function didSelectRowAt you can get the object using the index atIndexPath getting the object from the array you used to populate the tableView and send this object in the sender parameter: 该函数需要一个Any作为参数,因此在函数didSelectRowAt您可以使用索引atIndexPath获取该对象,该索引从用于填充tableView的数组中获取该对象,并在sender参数中发送该对象:

performSegue(withIdentifier: String, sender: Any?)

You should then implement this function: 然后,您应该实现此功能:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)

There you can retrieve your object in the sender and the view controller in the property segue.destination which is a UIViewController so you can convert it to your ViewController and pass the object to the next one. 在那里,您可以在sender segue.destination检索对象,并在属性segue.destination检索视图控制器,该属性是一个UIViewController因此您可以将其转换为ViewController并将该对象传递给下一个对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将数据从表视图传递到另一个视图 controller - How to pass the data from table view to another view controller 如何将不同的数据从表视图传递到另一个视图 controller - How to pass the different data from table view to another view controller 如何将信息从一个视图控制器中的表视图单元传递到另一视图控制器? - How do I pass information from a table view cell in one view controller to another view controller? 如何将视图 controller 中的数据传递到表视图 controller? - How to pass the data from view controller to the table view controller? 如何将表输出传递给另一个视图控制器? - How can I pass table output to another view controller? 如何将核心数据信息从表视图传递到视图控制器? - How can I pass core data information from a table view to a view controller? 将数据从表视图传递到视图控制器 - Pass data from table view to view controller 如何从 Firebase 检索数据,将其设置为全局变量,然后将其传递给下一个视图控制器? - How to retrieve data from Firebase, set it to a global variable, then pass it to the next view controller? 如何在IOS中将数据从一个视图传递到另一个视图控制器? - How to pass data from one view to another view controller in IOS? 如何从另一个视图控制器将数据插入到tableView中? - How can I insert data into a tableView from another view controller?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM