//In AppDelegate.m, I am forcing every window to LandScapeRight.
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskLandscapeRight;
}
//In ScanViewController.m, I am accessing camera and Image Library.
@implementation ScanViewController
-(void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
//Select photo from iPhone Image Library.
- (IBAction)photoFromAlbum:(id)sender
{
UIImagePickerController *photoPicker = [[UIImagePickerController alloc] init];
photoPicker.delegate = self;
photoPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:photoPicker animated:YES completion:NULL];
}
//Take photo from camera
- (IBAction)photoFromCamera:(id)sender
{
UIImagePickerController *photoPicker = [[UIImagePickerController alloc] init];
photoPicker.delegate = self;
photoPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:photoPicker animated:YES completion:NULL];
}
//Save the Image
- (void)imagePickerController:(UIImagePickerController *)photoPicker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
self.saveButton.enabled = YES;
self.filterButton.enabled = YES;
originalImage = [info valueForKey:UIImagePickerControllerOriginalImage];
[self.selectedImageView setImage:originalImage];
[self dismissViewControllerAnimated:YES completion:nil];
}
现在,我收到此错误" PLUICameraViewController shouldAutorotate返回YES"。我正在使用iOS 8,我希望我的应用程序能够在横向模式下工作,但是当我访问" ScanViewController.m"时,它可以是横向或纵向,因为我在iOS8中读到它,它是强制性的,访问相机时有纵向视图。任何建议都非常受欢迎。
答案 0 :(得分:0)
UICameraViewController仅支持纵向模式。 来自Apple文档:
重要
UIImagePickerController类仅支持纵向模式。此类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不得修改,但有一个例外。您可以将自定义视图分配给cameraOverlayView属性,并使用该视图显示其他信息或管理相机界面与代码之间的交互。
因此,您应该在supportedInterfaceOrientations上返回UIInterfaceOrientationMaskPortrait,并且您还应该在shouldAutorotate上返回NO。
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}