I'm working on an iOS Project using Swift. I have a ViewController
that is embedded in a UINavigationController
. I have my app associated with PDF
files in plist
. The user can open a PDF
emailed to them in the project. I know this then deals with:
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
if url != "" {
// Load from Mail App
incomingFileTransfer = url
incomingStatus = "Incoming"
/*let rootViewController = self.window!.rootViewController
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let setViewController = mainStoryboard.instantiateViewControllerWithIdentifier("MainMenu") as! MainMenuViewController
rootViewController?.navigationController?.popToViewController(setViewController, animated: false)*/
} else {
// Regular Load
print("App Delegate: No incoming file")
incomingFileTransfer = nil
}
return true
}
If the user is in another area of the app, and they open the app again from the PDF
, the app opens back to the area where they were. I want it to open to the first loaded ViewController
always. I looked here and tried to implement this in my section above in AppDelegate
with no luck. Can someone please help with this particularly in Swift? I'm not real great with converting Objective-C to Swift.
My ViewController
has a Title
set as MainMenu
:
This ViewController
has the UINavigationController
set as the Initial View
and a name of Main
:
The Storyboard
has a Storyboard ID
of Main
within the UINavigationController
Identity Inspector
:
Update:
Sorry. The url
is assigned to a Global Variable
that is then loaded into another ViewController
that has a WebView
.