iphone - '支持的方向与应用程序没有共同的方向,shouldAutorotate 返回 YES'

标签 iphone objective-c cocoa-touch ios5 ios6

<分区>

*我的 View 处于横向模式我正在保存图像并且我想要那个图像回来我的代码在下面并且我收到错误“由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'而终止应用程序,原因:'支持的方向与应用程序没有共同的方向,shouldAutorotate 返回 YES'"*我能为 iphone 做什么?

        `- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

         [self dismissModalViewControllerAnimated:YES];
         [picker release];

              }
             - (void)imagePickerController:(UIImagePickerController *)picker 

                didFinishPickingMediaWithInfo:(NSDictionary *)info {

            [picker dismissModalViewControllerAnimated:NO];

                imageDoodle.image = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];

                 }

               -(IBAction)loadfromalbumclicked:(id)sender

                 {

                UIImagePickerController * picker = [[UIImagePickerController alloc] init];

                picker.delegate = self;

                 picker.allowsEditing=NO;

        picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

               // self.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;

              [self presentModalViewController:picker animated:YES];
               }

              -(IBAction)savePrint{
//Save image to iOS Photo Library

                 UIImageWriteToSavedPhotosAlbum(imageDoodle.image, nil, nil, nil);
//Create message to explain image is saved to Photos app library
                 UIAlertView *savedAlert = [[UIAlertView alloc] initWithTitle:@"Saved"  

                message:@"Your picture has been saved to the photo library, view it in the 

               Photos app." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
//Display message alert
             [savedAlert show];
              }`

最佳答案

尝试将 shouldAutoRotate 设置为 NO,看看它是否有效。

您可以在 iOS 6.0 或更高版本中使用 shouldAutoRotate 和 supportedInterfaceOrientations 方法,而不是(已弃用的)shouldAutoRotateToInterfaceOrientation 方法。

像这样的——

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}


- (BOOL) shouldAutorotate {
    return YES;
}


- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}

关于iphone - '支持的方向与应用程序没有共同的方向,shouldAutorotate 返回 YES',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14456879/

相关文章:

javascript - 在 iPhone 和 Android 上通过 JavaScript 检测手指滑动

iphone - 如何在后台处理调度异步进程?

ios - Objective-C指针和swift

ios - 在 iOS 中更新 TwitterKit SDK

cocoa-touch - Runloop 在模拟器上工作在设备上失败

objective-c - 为不同的声音重用 AVAudioPlayer

iphone - 我们可以在不使用 APN 的情况下推送通知吗?

iphone - 在后台线程上接收 CLLocation 更新

objective-c - 解析 Twitter 获取状态 Objective C

iphone - UITableView,让页脚停留在屏幕底部?