Reputation: 388
How to dismiss popover when application enters in background?
Upvotes: 1
Views: 1039
Reputation: 12671
it is better to register your controller for UIApplicationDidEnterBackgroundNotification
or UIApplicationWillResignActiveNotification
and dismiss it whenever your app goes to background, this will make your life quite easier i feel.
registering for notification in your viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myMethod)
name:UIApplicationDidEnterBackgroundNotification object:nil];
implement the method and
-(void)myMethod{
// dismiss popview here
}
finally un-register from the notification in your view controller
-(void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
Upvotes: 5
Reputation: 5384
try this
- (void)applicationDidEnterBackground:(UIApplication *)application
{
//[popover dissmissPopoverAnimated:YES];
}
Upvotes: 0
Reputation: 933
Send an NSNotification
in your app delegate's willResignActive
method, and listen for it in your view controller that contains the popup, and have it dismiss said popover when the notification is received.
Upvotes: 4
Reputation: 9143
You can do this using the delegate method in appdelegate.m file
- (void)applicationDidEnterBackground:(UIApplication *)application
{
//put your dissmiss popover code here
}
Upvotes: 5