在 UITabBarController 中回调
Call Back in UITabBarController
我有一个 UITabBarController 和一个 class 将其命名为 ScreenLocker,在 UITabBarController/ViewDidApear 我使用回调初始化 ScreenLocker,c 秒后屏幕锁或当应用程序进入后台时应调用此回调,
class TabBarViewController: UITabBarController {
override func viewDidLoad() {
}
override func viewDidAppear(_ animated: Bool) {
lockAppCallBack()
}
func lockAppCallBack() {
let callBack = {
let myModalViewController = R.storyboard.authentication.authenticationViewController()
ScreenLocker.isAutoLocked = true
myModalViewController!.modalPresentationStyle = UIModalPresentationStyle.fullScreen
myModalViewController!.modalTransitionStyle = UIModalTransitionStyle.coverVertical
self.present(myModalViewController!, animated: true, completion: nil)
}
AuthenticationPatternPresenter.initScreenLocker(callBack: callBack)
}
屏幕锁
class ScreenLocker: NSObject{
static var isAutoLocked = false
static let instance : ScreenLocker = {
let instance = ScreenLocker()
return instance
}()
var timer:Timer!
var time:Int!
var callBack = {
}
func _init(time:Int, callBack: @escaping () -> ()){
self.time = time
self.callBack = callBack
}
每个选项卡都有一个 UINavigationController
一切正常,但是当我更改 UITabBarController 的选项卡并导航到下一个视图并返回到上一个视图时,选项卡的 ViewDidAppear 不会调用。
当我删除标签栏的 ViewDidAppear 时,一切正常,当我再次在标签栏中添加一个空的 ViewDidAppear 时,出现了同样的问题。 UITabBarController的ViewDidAppear有没有问题?有什么建议吗?
我有一个 UITabBarController 和一个 class 将其命名为 ScreenLocker,在 UITabBarController/ViewDidApear 我使用回调初始化 ScreenLocker,c 秒后屏幕锁或当应用程序进入后台时应调用此回调,
class TabBarViewController: UITabBarController {
override func viewDidLoad() {
}
override func viewDidAppear(_ animated: Bool) {
lockAppCallBack()
}
func lockAppCallBack() {
let callBack = {
let myModalViewController = R.storyboard.authentication.authenticationViewController()
ScreenLocker.isAutoLocked = true
myModalViewController!.modalPresentationStyle = UIModalPresentationStyle.fullScreen
myModalViewController!.modalTransitionStyle = UIModalTransitionStyle.coverVertical
self.present(myModalViewController!, animated: true, completion: nil)
}
AuthenticationPatternPresenter.initScreenLocker(callBack: callBack)
}
屏幕锁
class ScreenLocker: NSObject{
static var isAutoLocked = false
static let instance : ScreenLocker = {
let instance = ScreenLocker()
return instance
}()
var timer:Timer!
var time:Int!
var callBack = {
}
func _init(time:Int, callBack: @escaping () -> ()){
self.time = time
self.callBack = callBack
}
每个选项卡都有一个 UINavigationController 一切正常,但是当我更改 UITabBarController 的选项卡并导航到下一个视图并返回到上一个视图时,选项卡的 ViewDidAppear 不会调用。 当我删除标签栏的 ViewDidAppear 时,一切正常,当我再次在标签栏中添加一个空的 ViewDidAppear 时,出现了同样的问题。 UITabBarController的ViewDidAppear有没有问题?有什么建议吗?