【发布时间】:2018-05-01 13:15:36
【问题描述】:
我使用教程在应用程序委托中实现了一个方法,以从 safari 的 HTML 按钮打开特定的视图控制器。我的应用委托如下所示:
func application(_ app: UIApplication, open URL: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
print("url \(url)")
print("url host :\(url.host!)")
print("url path :\(url.path)")
let urlPath : String = (url.path as String?)!
let urlHost : String = (url.host as String?)!
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
if(urlHost != "mywebsite.ir")
{
print("Host is not correct")
return false
}
if(urlPath == "/index"){
let innerPage: ViewController = mainStoryboard.instantiateViewController(withIdentifier: "HomeViewController") as! ViewController
self.window?.rootViewController = innerPage
}
self.window?.makeKeyAndVisible()
return true
}
我的 HTML 按钮参考是:
<a href= "myapp://mywebsite.ir/index">open app</a>
但是当我的应用程序主页打开时,导航栏消失了,用户被卡住并且无法访问菜单按钮或后退按钮(在内部视图控制器的情况下)。
深度链接前后主视图控制器截图:
【问题讨论】:
标签: ios swift xcode deep-linking