我希望AddViewController自动关闭并在按下帖子后返回tableViewController。它一直都在工作,但是自从我将TableViewController更改为将TableView作为子视图的普通ViewController后,它不再起作用了……这是我的addVC的代码
@IBOutlet weak var postButton: CustomizableButton!
@IBOutlet weak var postBarButtonItem: UIBarButtonItem!
@IBOutlet weak var jobTextView: RoundText!
@IBAction func postPressed(_ sender: Any) {
if jobTextView.text != "" {
// Create and save a new job
let newJob = Job(text: jobTextView.text)
newJob.save()
}
}
override func viewDidLoad()
{
super.viewDidLoad()
self.navigationItem.rightBarButtonItem = postBarButtonItem
title = "What about your Job"
jobTextView.text = ""
jobTextView.becomeFirstResponder()
}
答案 0 :(得分:-1)
您如何展示AddViewController
?
如果以模态显示,则可以在dismiss(animated: true, completion: nil)
中进行postPressed
。
否则,如果它在导航堆栈中,则可以执行navigationController?.popViewController(animated: true)