【发布时间】:2020-01-24 15:31:30
【问题描述】:
在我的应用中,我使用的是revealingSplashView。
用户既可以登录,也可以更改起始ViewController:
class MainNavigationControllerViewController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
if isLoggedIn() {
let homeController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "HomeVC")
viewControllers = [homeController]
}
}
fileprivate func isLoggedIn() -> Bool {
return UserDefaults.standard.isLoggedIn()
}
}
或用户未登录,因此显示FirstLaunchViewController,用户可以从该位置登录并访问MainViewController。
目前我在FirstLaunchViewController 中展示revealingSplashView,如下所示:
let revealingSplashView = RevealingSplashView(iconImage: UIImage(named: "zauberstab")!, iconInitialSize: CGSize(width: 120, height: 120), backgroundColor: .white)
revealingSplashView.startAnimation()
问题是,如果用户已登录,我也希望拥有该动画,因此 MainViewController 是起始 VC。我知道我可以将代码从FirstLaunchViewController 复制到MainViewController,但这会在用户登录并到达MainViewController 时导致问题,即使它只应在应用程序启动后显示,动画也会显示。
【问题讨论】:
-
为什么不直接将 appDelegate 中的
revealingSplashView代码移动到didFinishLaunch中,这样它就会一直被调用。用户是否登录。 -
我究竟是如何实现这个的?我尝试在
didFinishLaunchingWithOptions中添加这两行,但这没有任何作用 -
这是我的 git:github.com/DieGlueckswurst/Wishlist 如果有帮助的话
标签: ios swift animation uiview uiviewcontroller