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];
}
Source:
http://stackoverflow.com/questions/15224245/dismiss-popover-when-app-goes-in-background