【发布时间】:2017-10-28 19:24:07
【问题描述】:
我有一个名为 PostsTableView 的 tableview,它有一个用户帖子列表,其中包含一个名为“Comment”的 UIButton。当用户单击 Comment 时,我希望它重定向到 CommentViewController,其中包含帖子周围的所有信息,例如 postText 和撰写帖子的用户。
下面的代码片段。
PostsTableView
extension PostsTableViewController: PostsTableViewCellDelegate {
func commentTapped(postInfo: String) {
//How do I pass postInfo along to CommentViewController
}
PostsTableViewCell
protocol TableViewCellDelegate {
func commentTapped(postInfo: String)
}
class PostsTableViewCell: UITableViewCell {
@IBOutlet weak var postTextLabel: UILabel!
@IBOutlet weak var postUserLabel: UILabel!
var postItem: Post!
var delegate: TableViewCellDelegate?
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
@IBAction func commentAction(_ sender: Any) {
delegate?.commentTapped(postInfo: postItem.postText)
}
}
【问题讨论】:
标签: swift firebase swift3 firebase-realtime-database