I really don't think this can be done, but still my boss wants me to provide a link where it says so. What he wants is to add an 'are you sure you want to exit?' warning when the user presses the home button, and if the user says 'no' the app won't go inactive. It can't be done, can it?
相关问题
- 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
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
I know I'm too late to answer this question.
But I recently came with the issue which Samssonart had.
The answer given by @iandotkelly is deprecated with iOS5. Now none of delegate method will be used to distinguish between locking the device or sending app to background using Home button.
you can now use applicationState variable to define what action is triggered.
applicationState is an inbuilt id provided by appDelegate.
**
**
So, in your case you can check out this condition in
**applicationDidEnterBackground**
methodEnjoy Programming!
I know this is an old topic, but I just want to update this answer. In iOS 7 this is not working. So I use screenbrightness when the app will go to the background to identify difference between the Home and Lock button.
-(void)applicationDidEnterBackground:(UIApplication *)application { if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateInactive) { NSLog(@"Sleep button pressed"); } else if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) { if ([[UIScreen mainScreen] brightness] > 0.0) NSLog(@"Home button pressed"); else NSLog(@"Sleep button pressed"); } }
I hope this is gonna be of any help for in future for anyone