【发布时间】:2020-08-26 04:03:25
【问题描述】:
我是 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 {
}
【问题讨论】:
标签: swift storyboard viewcontroller uibarbuttonitem