我正在使用 Swift 开发一个 iOS 项目。我有一个嵌入在 UINavigationController
中的 ViewController
。我的应用程序与 plist
中的 PDF
文件关联。用户可以在项目中打开通过电子邮件发送给他们的 PDF
。我知道这涉及到:
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
}
如果用户位于应用程序的另一个区域,并且他们再次从 PDF
打开应用程序,则应用程序将打开回他们所在的区域。我希望它始终打开第一个加载的 ViewController 。我看了here并尝试在上面的 AppDelegate
部分中实现这一点,但没有成功。有人可以帮忙解决这个问题,特别是在 Swift 中吗?我不太擅长将 Objective-C 转换为 Swift。
我的ViewController
有一个Title
设置为MainMenu
:
此ViewController
将UINavigationController
设置为初始 View
,名称为Main
:
Storyboard
在 UINavigationController
Identity Inspector
中具有 Main
的 Storyboard ID
>:
更新:
抱歉。 url
被分配给一个全局变量
,然后加载到另一个具有 WebView
的 ViewController
中。
最佳答案
关于swift - 使用 Swift2 从 AppDelegate 重新打开 iOS 应用程序到指定的导航 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35206531/