我是Swift的初学者,但我还不了解所有要素。
我正在尝试从另一个ViewController(ProjectInfosViewController)执行ViewController(ProjectTabBarController)中存在的功能。当我从第二个开始执行函数时,我最终会出错。
对于上下文,它是属于UITabBarViewController的3个UIViewController的导航按钮,其本身嵌入在UINavigationController中
谢谢您! (对不起,我的英语不好)
import UIKit
//MARK:-TAB CONTROLLER
class ProjectTabBarController: UITabBarController {
@IBOutlet weak var ui_saveButton: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func saveAction(_ sender: Any) {
// code
disableSaveButton() // ALL IT'S FINE HERE
}
func enableSaveButton() {
ui_saveButton.title = "Save"
ui_saveButton.isEnabled = true
}
func disableSaveButton() {
ui_saveButton.title = "Saved"
ui_saveButton.isEnabled = false
} }
//MARK:-PROJECT INFORMATIONS
class ProjectInfosViewController: UIViewController, UITextFieldDelegate {
let superController = ProjectTabBarController()
override func viewDidLoad() {
super.viewDidLoad()
}
func textFieldDidChangeSelection(_ textField: UITextField) {
superController.enableSaveButton() // BUT HERE, DOESN'T
} }
//MARK:-PROJECT FIXTURES
class ProjectFixturesViewController: UIViewController, UITableViewDataSource {
}
//MARK:-PROJECT CONTACT
class ProjectContactViewController: UIViewController {
}