Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to determine when iOS widget hides?

Is there any way to catch the moment when a user hides the notification panel with a widget? I want to save some information into the database at that moment (I want it to be similar to applicationDidEnterBackground:). Any other ideas about how to save data at the last moment would also be appreciated.

like image 376
Accid Bright Avatar asked Jan 21 '26 16:01

Accid Bright


1 Answers

Usually, your widget would be a UIViewController instance, conforming to the NCWidgetProviding protocol. That means, that you can take advantage of UIViewController's functionality and execute your code in

- (void)viewWillDisappear:(BOOL)animated;

or

- (void)viewDidDisappear:(BOOL)animated;

I tested it and it worked.

like image 123
Andrew Avatar answered Jan 23 '26 09:01

Andrew