【问题标题】:shouldAutorotateToInterfaceOrientation in ios6ios6中的shouldAutorotateToInterfaceOrientation
【发布时间】:2012-11-08 11:02:05
【问题描述】:

我正在使用UIImagePickerviewController 通过以下附加代码打开照片库...在调用位行代码之后。应用程序崩溃了...它在ios5 中运行良好

UIImagePickerController* content = [[UIImagePickerController alloc] init];
content.delegate = self;
content.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController:content animated:YES];
[content release];

这段代码有什么问题吗?

【问题讨论】:

  • 我前几天也遇到了这个问题,让我看看我是怎么解决的。
  • 我认为它与自动布局有关。您是否在放置 uiimagepicker 的视图上启用了自动布局?
  • 哦,ios6 中不推荐使用 shouldAutoRotateToInterfaceOrientation:改用supportedInterfaceOrientations 和preferredInterfaceOrientationForPresentation 方法。
  • 我已按照您给出的程序进行操作,但什么都不会发生,我的代码在这里而不是使用 shouldAutorotateToInterfaceOrientation:-(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeRight; }

标签: ios uinavigationcontroller uiinterfaceorientation


【解决方案1】:

检查Crash on presenting UIImagePickerController under ios6 您将获得使UIImagePickerviewController 在iOS 6.0 上运行所需的一切。

【讨论】:

    【解决方案2】:
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
      popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
      [popover presentPopoverFromRect:cameraButton.frame inView:self.view  
      permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    }
    else{
     [self presentModalViewController:imagePicker animated:YES];
    }
    

    【讨论】:

      【解决方案3】:

      我有同样的问题。因为UIImagePicker 以纵向模式显示。 我通过继承UIImagePicker 并实现shouldAutorotate 方法来修复它,例如:

      - (BOOL)shouldAutorotate
      {
          return NO;
      }
      

      我创建了我的子类 imagePicker 的实例而不是 UIImagePicker,一切正常。希望这会对你有所帮助。

      【讨论】:

      • 最后我解决了这个方向问题并通过 UIImagePicker 的子类使应用程序崩溃,并且我包含了以下方法 - (BOOL)shouldAutorotate { return NO; }
      • @StalinPusparaj:如果它解决了您的问题,我不会得到 +1 :)。请接受答案:)
      • 因此,当我们投赞成票时,我们通常会说 +1 :) 这就是我想的原因。好的哥们儿。无论如何感谢您的评论:)
      • @StalinPusparaj:如果有效,请接受答案:)
      • 嗨它在 ios6 上对我不起作用。知道我该怎么做吗?它仍然旋转选择器
      猜你喜欢
      • 2012-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-19
      • 1970-01-01
      • 2011-04-22
      • 2011-02-21
      相关资源
      最近更新 更多