//注册进入前台的通知
NotificationCenter.default.addObserver(self, selector:#selector(becomeActive), name: UIApplication.didBecomeActiveNotification, object: nil)
//注册进入后台的通知
NotificationCenter.default.addObserver(self, selector:#selector(becomeDeath), name: UIApplication.willResignActiveNotification, object: nil)
//必须要加@objc-----进入前台
@objc func becomeActive(noti:Notification){
print("进入前台")
}
//必须要加@objc----进后台
@objc func becomeDeath(noti:Notification){
print("进入后台")
}
iOS/swift之进入前后台通知
猜你喜欢
转载自blog.csdn.net/u011146511/article/details/86001504
今日推荐
周排行