1

I my application i want to hide the UIPickerview controller when application enter's in a paused state?

for eg: in my viewcontroller i am using uipickerview,and is placed in a popovercontroller,but i have not dismiss the popovercontroller and the application goes in a paused state. when user open the application the uipikcer view is displayed which i want to dismiss.

please help me out with this.

Dalee Davis
  • 981
  • 8
  • 19
Nilesh .S. Joshi
  • 567
  • 2
  • 9
  • 26

2 Answers2

2

Use NSNotificationCenter for hide the UIPickerView when application go in background like bellow...

[[NSNotificationCenter defaultCenter] addObserver:alertView selector:@selector(HidePickerView) name:@"UIApplicationWillResignActiveNotification" object:nil];

and hide the UIPickerView in bellow method..

- (void) HidePickerView {
      [yourPickerView setHidden:YES];
}
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
1

You need to subscribe for the UIApplicationWillResignActiveNotification notification and when it's fired and your selector is called, you should [self.myPickerView dismissViewControllerAnimated:NO completion:nil];.
Note: -viewWillDisappear: method would not be called when the app is resigning active.

graver
  • 15,183
  • 4
  • 46
  • 62