我只需要为我的项目做同样的事情。这是我的解决方案。
我创建了一个 ViewController 并将其设置为 Main.storyboard 中的 Storyboard 入口点。我以前有一个 TabViewController 有各种设置,只需要在那里进行 1 次更改。
TabBarController 应该有一个 StoryboardID,我命名为“TabBarID”。
我创建了一个新的 LaunchViewController swift 文件,并将新的 ViewController 添加到我的 Main.storyboard 并在 Main.storyboard 中分配它。
这是那个类。非常简单,有一个计时器,一旦超过阈值,TabBarViewController 就会全屏显示。
class LaunchViewController: UIViewController {
var timer = Timer()
var time = 0
var threshold = 2
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundTheme(theme: .orangeWhite)
Timer.scheduledTimer(timeInterval: 1, target: self, selector: (#selector(updateTimer)), userInfo: nil, repeats: true)
}
@objc func updateTimer() {
time += 1
if time > threshold {
timer.invalidate()
guard let storyboard = self.storyboard else {
//failed to find storyboard
return
}
let tabBarController = storyboard.instantiateViewController(identifier: "TabBarID")
tabBarController.modalPresentationStyle = .fullScreen
present(tabBarController, animated: true, completion: nil)
}
}
}