2017-09-08 10 views
0

目的のcビューコントローラをswiftクラスファイルからプッシュすることは可能ですか? "宣言されていない型 'DashboardDetailsViewController' の使用" などのエラーを取得Objective c View Controllerクラスをストーリーボードを使用してswiftクラスから呼び出すことはできますか?

後述するように、私が試した

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) 
} 

。クラスファイルをインポートしようとしました。これを解決するための回避策はありますか? TIA。

+1

ブリッジヘッダーを使用してみましたか? –

+0

ブラインドヘッダークラ​​スに私のヘッダーを追加することを全く忘れてしまった。ありがとう。 – user579911

答えて

0

新しいファイル"ModuleName-Bridging-Header.h"を作成し、このファイルに import "YourObjectiveCViewController.h"を作成して開きます。

希望します。

+0

@ user579911私のソリューションがあなたの問題を解決するならば、それをアップアップして回答にすることができます。ありがとう –

関連する問題