【发布时间】:2017-09-08 04:15:14
【问题描述】:
是否可以从 swift 类文件中推送目标 c 视图控制器?
我尝试了如下所述,
import UIKit
class DashboardViewController: UIViewController {
@IBOutlet weak var submitButton: UIButton!
class func instantiate() -> DashboardViewController {
let storyboard = UIStoryboard(name: "DashboardView", bundle: Bundle.main)
return storyboard.instantiateViewController(withIdentifier: "dashboardVC") as! DashboardViewController
}
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func userClickedSubmitButton(_ sender: Any) {
//let dashboardDetailsVC = DashboardDetailsViewController.instantiate()
//self.navigationController?.pushViewController(dashboardDetailsVC!, animated: true)
let storyBoard: UIStoryboard = UIStoryboard(name: "DashboardDetails", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "dashDetails") as! DashboardDetailsViewController
self.present(newViewController, animated: true, completion: nil)
}
收到错误为“使用未声明的类型'DashboardDetailsViewController'”。我什至尝试导入类文件。有什么办法可以解决这个问题吗? TIA。
【问题讨论】:
-
你试过使用桥接头吗?
-
我完全忘记在 bring header 类中添加我的 header。谢谢。
标签: ios objective-c swift uiviewcontroller