プッシュ通知から詳細ビューを開くアプリを実行しています。 AppDelegateでは、ビューを開いていますが、ビューにNavigation Controllerがありません。
次に、私の解決策はメソッドを使用すると思います instantiateViewControllerWithIdentifier
Navigation Controllerを処理するために、これが解決策であるかどうかはわかりませんが、ここにタイトルの質問があります...
私のクラス SlideNavigationController
Objective-Cであり、メソッドを使用するとき
let rootVC = UIStoryboard(name: "Main", bundle: nil).
instantiateViewControllerWithIdentifier("SlideNavigationController") as! SlideNavigationController
私はエラーが表示されます:
警告:Objective-Cクラス情報をロードできませんでした。これにより利用可能な型情報の品質が大幅に低下します。
何か案が?英語で申し訳ありませんが、編集は大歓迎です!ありがとう
UIControllerの問題は解決されました。ここに私のコードがあります:
let rootViewController = self.window!.rootViewController as! UINavigationController
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let targerView = mainStoryboard.instantiateViewControllerWithIdentifier("view_place_detail") as! VCPlaceDetailTour
targerView.placeId = aps as String
rootViewController.pushViewController(targerView, animated: false)
回答:
回答№1は2このコードでできます。
let rootViewController = self.window!.rootViewController as! UINavigationController
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let targerView = mainStoryboard.instantiateViewControllerWithIdentifier("view Identifier") as! PromotionDetailsVC
rootViewController.pushViewController(targerView, animated: false)
これがあなたに役立つことを願っています。
回答№2の場合は1
プログラムでナビゲーションを作成できますコントローラーを使用して、目的のView ControllerをNavigation ControllerのrootViewControllerとして設定し、Navigation ControllerをWindowsのrootViewControllerとして設定します。
例:
let rootVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("SlideNavigationController") as! SlideNavigationController
let window = UIApplication.sharedApplication().keyWindow
window.rootViewController = rootVC
このリンクでも同じことが検証されます。 appdelegateで初期ViewControllerを設定する-swift
回答№3の場合は1
swiftプロジェクトで客観的なcコントローラーを使用するには、ブリッジングヘッダーを作成する必要があります。
ブリッジングヘッダーの作成については、以下のリンクを参照してください。
Bridging-Header.hのパスを見つける方法-Swift、Xcode
その後、コントローラの.hファイルをブリッジングヘッダーファイルにインポートする必要があります。
これで、Swiftプロジェクトで目的のCビューコントローラーを簡単に使用できます。