通过 url 设置 ViewController 并将其显示为弹出窗口
Setting up a ViewController via url and show it as a popup
我目前有一种方法可以用来设置新的 ViewController
func setRootView(viewController vc: UIViewController){
UIApplication.shared.windows.first?.rootViewController = vc
UIApplication.shared.windows.first?.makeKeyAndVisible()
}
如何修改 ViewController 将显示在其他屏幕上的演示文稿,如演示文稿样式,而不是模态?
这是在按下按钮后调用的函数,视图应该改变:
func moveToNextVC(isLogin: Bool){
if self.checkNetworkConnection(){
let vc = HomeVC(nibName: "HomeVC", bundle: nil)
if isLogin{
vc.modalPresentationStyle = .automatic
vc.url = loginLink
}else{
vc.modalPresentationStyle = .automatic
vc.url = signupLink
}
setRootView(viewController: vc)
}
else{
showAlert("Alert!", message: "Please check your internet connection, then try again.")
}
}
根据 :
Instead of doing this UIApplication.shared.windows.first?.rootViewController = vc
, I would do present(vc, animated: true)
这解决了问题。
我目前有一种方法可以用来设置新的 ViewController
func setRootView(viewController vc: UIViewController){
UIApplication.shared.windows.first?.rootViewController = vc
UIApplication.shared.windows.first?.makeKeyAndVisible()
}
如何修改 ViewController 将显示在其他屏幕上的演示文稿,如演示文稿样式,而不是模态?
这是在按下按钮后调用的函数,视图应该改变:
func moveToNextVC(isLogin: Bool){
if self.checkNetworkConnection(){
let vc = HomeVC(nibName: "HomeVC", bundle: nil)
if isLogin{
vc.modalPresentationStyle = .automatic
vc.url = loginLink
}else{
vc.modalPresentationStyle = .automatic
vc.url = signupLink
}
setRootView(viewController: vc)
}
else{
showAlert("Alert!", message: "Please check your internet connection, then try again.")
}
}
根据
Instead of doing this
UIApplication.shared.windows.first?.rootViewController = vc
, I would dopresent(vc, animated: true)
这解决了问题。