I'm new in iOS Programming. I want to ask is there any method that equivalent with applicationdidbecomeactive for UIViewController in UIView? I need to update my view everytime it's become active after running in the background. Thank you!
I'm new in iOS Programming. I want to ask is there any method that equivalent with applicationdidbecomeactive for UIViewController in UIView? I need to update my view everytime it's become active after running in the background. Thank you!
You can use NotificationCenter here.
You can register an observer in view in which you want the notification.
NotificationCenter.default.addObserver(self, selector: #selector(appIsActivited), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil)
When app becomes active then a notification is fired and appIsActivited method will be called.
@objc func appIsActivited() {
//do something
}
Note: Don't forgot to remove observer from view once it is no more needed to releases view's occupied memory.