So I am writing this iPad app that starts on a main screen and then from there you can go to a settings page. In the settings page you have the ability to select a picture from the photo album using a UIImagePickerController
in a popover view.
If I go to the settings page and then press the back button to return to the main page everything works as expected. But if I go to settings and pick an image the back button on the page will not let me go back to the main page.
The popover and UIImagePickerController
seem to be working fine so I do not know what is causing this. Here is my code for the UIImagePickerController
.
- (IBAction)imagePick1:(id)sender {
pickerController = [[UIImagePickerController alloc] init];
[pickerController setDelegate:self];
[pickerController setSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum];
[pickerController setAllowsEditing:NO];
popoverController = [[UIPopoverController alloc] initWithContentViewController:pickerController];
[popoverController setDelegate:self];
[popoverController presentPopoverFromRect:[[self imageButton1] frame] inView:[self view] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
...
- (void)imagePickerController:(UIImagePickerController *)pickerController1 didFinishPickingMediaWithInfo:(NSDictionary *)info
{
image1 = [info objectForKey:UIImagePickerControllerOriginalImage];
_image1.image = image1;
[popoverController dismissPopoverAnimated:YES];
}
When I try to press the back button the app freezes and it won't respond to any more commands. What am I doing wrong?
Edit: I ran it again and this is the error I got in the log when pressing the back button.
-[__NSCFType dismissPopoverAnimated:]: unrecognized selector sent to instance 0x7128cd0
Also here is the beginning of my header file.
@interface ViewController : UIViewController
<UIPickerViewDataSource, UIPickerViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIPopoverControllerDelegate>{
UIPopoverController *popoverController;
}
@property (nonatomic, retain) UIPopoverController *popoverController;