Possible Duplicate:
UIPopovercontroller dealloc reached while popover is still visible
Im creating a universal app and trying to get an image selected from Camera roll. Works fine on iPhone, iPad wants a pop over, so have done that, now keep getting an error
-[UIPopoverController dealloc] reached while popover is still visible.
Ive researched:
and google, nothing has solved this issue
Stuck now, any advice appreciated
Ive implemented the popover delegate in .h
.m
- (void)logoButtonPressed:(id)sender /////////////iPad requires seperate method ////////////////
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
LogCmd();
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
////////
imagePicker.modalPresentationStyle = UIModalPresentationCurrentContext;
////////
[self presentModalViewController:imagePicker animated:YES];
}
else
{
// We are using an iPad
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
UIPopoverController *popoverController=[[UIPopoverController alloc] initWithContentViewController:imagePickerController];
popoverController.delegate=self;
[popoverController presentPopoverFromRect:((UIButton *)sender).bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
I have also now tried this:
.h
@property (strong) UIPopoverController *pop;
.m
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { ///code added
LogCmd();
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
[self presentModalViewController:imagePicker animated:YES];
///code added////////////////////////////
}
else {
if (self.pop) {
[self.pop dismissPopoverAnimated:YES];
}
// If usingiPad
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
UIPopoverController *popoverController=[[UIPopoverController alloc] initWithContentViewController:imagePickerController];
[popoverController presentPopoverFromRect:((UIButton *)sender).bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];