您好我正在尝试使用按钮将数据从视图控制器传递到tablevievcontroller,但是当我单击按钮时,只有表格视图控制器没有导航和标签栏,我该怎么办?
这是我的代码
import Foundation
import UIKit
import Firebase
import FirebaseDatabase
import os.log
class informationViewController: UIViewController, UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@IBOutlet weak var favbutton: UIButton!
@IBOutlet weak var pName: UILabel!
var obj = SearchTableViewController()
@IBOutlet weak var history: UITextView!
var historyStanbul : HistoricalPlace?
let appDelegate = UIApplication.shared.delegate as! AppDelegate
override func viewDidLoad() {
super.viewDidLoad()
if let history1 = historyStanbul{
navigationItem.title = history1.historyName
pName.text = history1.historyName
history.text = history1.information
}
}
@IBAction func favButton(_ sender: Any) {
let user = pName.text
DispatchQueue.main.async(){
self.performSegue(withIdentifier: "senddata", sender: self)
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
super.prepare(for: segue, sender: sender)
/* if let dest = segue.destination as? favTableViewController {
if let name = sender as? String {
dest.place.name = pName.text
dest.place.information = history.text
appDelegate.favplaces.append(dest.place)
}
}*/
switch(segue.identifier ?? "") {
case "senddata":
guard let mealDetailViewController = segue.destination as? favTableViewController else {
fatalError("Unexpected destination: \(segue.destination)")
}
let dest = segue.destination as? favTableViewController
dest?.place.name = pName.text
dest?.place.information = history.text
appDelegate.favplaces.append((dest?.place)!)
default:
fatalError("Unexpected Segue Identifier; \(String(describing: segue.identifier))")
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
and here is my story board
粉红色标记的tableviewcontroller,这是我的目的地。发件人是vievcontroller,里面包含明星