I need to know how to open the gallery in iPhone SDK. I believe my code is correct, but I'm still getting an exception.
This is my code:
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
imgpkrController.delegate = self;
imgpkrController.allowsEditing = YES;
imgpkrController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
//[self presentModalViewController:(UIViewController *)imgpkrController animated:YES];
[self presentViewController:(UIViewController *)imgpkrController animated:YES completion:nil];}
By using this code the am getting the exception:
UIApplicationInvalidInterfaceOrientation', reason:
preferredInterfaceOrientationForPresentation must return a supported interface orientation!
So I tried this code:
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
UIInterfaceOrientation interface = [[UIApplication sharedApplication] statusBarOrientation];
if(interface == UIDeviceOrientationPortrait)
{
imgpkrController.delegate = self;
imgpkrController.allowsEditing = YES;
imgpkrController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
//[self presentModalViewController:(UIViewController *)imgpkrController animated:YES];
[self presentViewController:(UIViewController *)imgpkrController animated:YES completion:nil];
}else if (interface ==UIDeviceOrientationLandscapeLeft || interface ==UIDeviceOrientationLandscapeRight)
{
imgpkrController.delegate = self;
imgpkrController.allowsEditing = YES;
imgpkrController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
//[self presentModalViewController:(UIViewController *)imgpkrController animated:YES];
[self presentViewController:(UIViewController *)imgpkrController animated:YES completion:nil];}}
But this gives the same exception. Can anybody help me out with this?