pcg26 pcg26 - 5 months ago 38
Swift Question

Notification action open view without Navigation Controller

I'm doing an app which opens a detail view from a push notification.
In my AppDelegate I'm opening the view, but the view doesn't have a navigation controller.

Then I think that my solution is use the method

instantiateViewControllerWithIdentifier

to handle the navigation controller, I'm not sure if this is the solution, but here is the question of the title...

My class
SlideNavigationController
is Objective-C, and when I use the method

let rootVC = UIStoryboard(name: "Main", bundle: nil).
instantiateViewControllerWithIdentifier("SlideNavigationController") as! SlideNavigationController


I get the error:


warning: could not load any Objective-C class information. This will significantly reduce the quality of type information available.


Any idea? Sorry for my English, edits are welcome! Thanks

The problem with my UIController is solved. Here is my code:

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)

Answer

You can do with this code.

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)

I hope this will help you.