16

*私のビューはランドスケープ モードです。画像を保存していますが、その画像を元に戻したいと思っています。私のコードは以下で、「キャッチされない例外 '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];
              }`
4

7 に答える 7

16

shouldAutoRotate を NO に設定してみて、動作するかどうかを確認してください。

iOS 6.0 以降では、(非推奨の) shouldAutoRotateToInterfaceOrientation メソッドの代わりに、shouldAutoRotate および supportedInterfaceOrientations メソッドを使用できます。

このようなもの -

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}


- (BOOL) shouldAutorotate {
    return YES;
}


- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}
于 2013-01-22T11:33:22.837 に答える
6

横向きまたは縦向きの限定された向きのみをサポートしています。しかし、View Controller で別の向きを呼び出しています。

次の画像は、サポートされている方向を示しています。横向きの右と横向きの左のみをサポートしているため、縦向きに呼び出すと、あなたのようにエラーが表示されます。したがって、両方の方向をサポートしたい場合は、概要で変更してください。

ここに画像の説明を入力

詳細については、この回答を参照してください。 それが役に立てば幸い。

編集

したがって、このコードをビューコントローラーに配置する必要があります

  - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
  return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |   UIInterfaceOrientationMaskLandscapeRight;
 }
于 2013-01-22T11:00:46.957 に答える
5

このエラーは、plist でサポートされているインターフェイスの向きと、によって返された向きが一致しない場合にスローされます。-(NSUInteger)supportedInterfaceOrientations

NSUIntegerによって返されるはUIInterfaceOrientationMasksupportedInterfaceOrientationsでなければならないことに注意してください。

例えば

- (NSUInteger) supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
    // and NOT UIInterfaceOrientationPortrait;
}
于 2013-11-12T10:14:03.537 に答える
4

UIImagePickerControllerまたはを使用UIPopoverControllerしてこれらerrorが発生した場合、これらの以下の解決策は非常に優れています。

また、これらのエラーiOS 6.0のみが発生します

新しいものUIImagePickerController's categoryを作成し、add

@implementation UIImagePickerController(custom)

  -(BOOL)shouldAutorotate
  {
    return NO;
  }
@end

それは私にとってはうまくいきます。

于 2014-02-25T10:22:57.970 に答える
0

iOS 6.0 の場合、アプリが横向きモードのみをサポートしている場合、UIImagePickerController をポップアップするとクラッシュします。

私の解決策は、以下のカテゴリを UIImagePickerController に追加することです:

@interface UIImagePickerController (oritation)

@end

@implementation UIImagePickerController (oritation)

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

@end
于 2013-10-23T07:05:37.083 に答える