is there any way to know the state of my application if it is in background mode or in foreground . Thanks
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- Using if let syntax in switch statement
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Unable to process app at this time due to a genera
- Enum with associated value conforming to CaseItera
you can add a boolean when the application enter in background or enter in foreground. You have this information by using the App delegate.
According the Apple documentation, maybe you can also use the mainWindow property of your Application or the active status property of the app.
NSApplication documentation
[UIApplication sharedApplication].applicationState
will return current state of applications such as:or if you want to access via notification see UIApplicationDidBecomeActiveNotification
Swift 3+
Objective C
Swift 3
Swift 4
If somebody wants it in swift 3.0
for swift 4