相关疑难解决方法(0)

在iOS 6.0下展示UIImagePickerController时崩溃

我的应用程序仅通过supportedInterfaceOrientation属性支持横向方向.

使用iOS 6之前的iOS,我的应用程序可以成功加载UIImagePickerControllervia 的实例,presentViewController:animated:completion:即使它UIImagePickerController本身只支持纵向方向.

图像选择器简单地向用户侧面呈现.用户旋转手机,拾取他们的图像,然后旋转回横向.

在iOS 6.0下,presentViewController:animated:completion:使用UIImagePickerController实例调用会使应用程序崩溃.我可以通过向我的supportedInterfaceOrientation属性添加纵向选项来防止崩溃.

但是,纵向操作对我的应用来说真的没有用.我原本以为我可以使用shouldAutorotateToInterfaceOrientation该应用程序"支持肖像",但只允许在这一个视图中旋转到肖像.但是现在该方法已被弃用,我不能在shouldAutorotate中使用相同的技术.

有没有人有任何想法如何在iOS 6.0下解决这个问题?

landscape orientation ios6

41
推荐指数
3
解决办法
2万
查看次数

iOS7 iPad仅限应用程序,使用UIImagePickerController

我相信这是一个常见的问题,许多答案不再适用,很多只是部分,如果你在iOS7下,你的iPad应用程序只是Landscape,但你想使用UIImagePickerControllerwith source UIImagePickerControllerSourceTypePhotoLibraryUIImagePickerControllerSourceTypeCamera.

如何设置正确,所以它100%工作?并且您没有获得混合方向并避免错误"支持的方向与应用程序没有共同的方向,并shouldAutorotate返回YES".

cocoa-touch uiimagepickercontroller ipad uiinterfaceorientation ios

32
推荐指数
2
解决办法
2万
查看次数

仅支持iOS 6的一个视图的不同方向

我想在我的应用程序中仅旋转我的一个视图,无论是横向左侧还是横向右侧.我的所有其他视图都处于纵向模式,我已将我的应用程序设置为仅支持纵向模式.在iOS 6中改变方向,我不知道如何做到这一点.我试过下面发布的以下内容.谁能告诉我我做错了什么?谢谢!

-(BOOL)shouldAutorotate {
return YES;
}

-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
} 
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(didRotate:)
                                            name:UIDeviceOrientationDidChangeNotification
                                           object:nil];
return YES;//UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
} 


 -(void)didRotate:(NSNotification *)notification {
 UIDeviceOrientation orientation = [[notification object] orientation];

if (orientation == UIDeviceOrientationLandscapeLeft) {
    [theImage setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)];
    [self.view setTransform:CGAffineTransformMakeRotation(M_PI / 2.0)];
} else if (orientation == UIDeviceOrientationLandscapeRight) {
    [theImage setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)];
    [self.view setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)];
} else if (orientation == …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c ios

29
推荐指数
2
解决办法
3万
查看次数

'支持的方向与应用程序没有共同的方向,并且应该返回'是'

*我的观点是在陆地景观模式我正在保存图像,我希望该图像回来,我的代码在下面,我发现错误"终止应用程序由于未捕获的异常'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 …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c ios5 ios6

15
推荐指数
3
解决办法
3万
查看次数

iOS:如果与"消息"选项共享则崩溃

我们的应用仅支持纵向模式.介绍UIActivityViewController的工作原理.

但是,与"消息"选项共享会导致应用崩溃:

***由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'而终止应用程序,原因:'支持的方向与应用程序没有共同的方向,[MFMessageComposeViewController shouldAutorotate]返回YES'

与另一个选项共享,例如Facebook Messenger,可以使用.

像这样的类似SO问题的解决方案不起作用,因为他们建议支持所有方向.我们只想支持肖像.

1)我们如何支持"消息"共享选项,同时仅支持纵向方向,即仅支持Info.plist中的纵向方向?

2)为什么我们能够在Info.plist中仅支持纵向的其他应用程序中支持"消息"共享选项,但不支持此选项?我们应该在哪里寻找调试目的?

    // Define share objects
    let objectsToShare = ["test message"] as [Any]

    // Configure UIActivityViewController
    let activityViewController = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
    activityViewController.excludedActivityTypes =
        [UIActivityType.addToReadingList,
         UIActivityType.assignToContact,
         UIActivityType.print,
         UIActivityType.copyToPasteboard]

    // Define completion handler
    activityViewController.completionWithItemsHandler = doneSharingHandler

    // Show UIActivityViewController
    present(activityViewController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

ios mfmessagecomposeviewcontroller uiactivityviewcontroller swift

6
推荐指数
1
解决办法
699
查看次数

iOS错误:支持的方向与应用程序(iPhone)没有共同的方向

使用iOS 8.3

我在横向模式下有一个视图,我正在尝试打开一个仅限肖像的视图控制器.每次我尝试打开它,应用程序崩溃.

我已经阅读了这个官方的苹果答案,基本上建议做以下事情:

在app委托中:

@implementation AppDelegate

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        return UIInterfaceOrientationMaskAll;
    else  /* iphone */
        return UIInterfaceOrientationMaskAllButUpsideDown;
} 
Run Code Online (Sandbox Code Playgroud)

在我的控制器中:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}
Run Code Online (Sandbox Code Playgroud)

所以我有,但我仍然得到这个崩溃消息:

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES
Run Code Online (Sandbox Code Playgroud)

在项目常规设置中,我有以下(不应根据苹果的答案进行更改):

设置

我可以看到这些函数实际上被调用但没有任何帮助.有什么想法吗?

我之前读过的一些问题:

如何在iOS 6中强制UIViewController为Portrait方向

iOS6:supportedInterfaceOrientations不工作(调用但接口仍然旋转)

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

iphone objective-c uiimagepickercontroller ios

5
推荐指数
1
解决办法
1万
查看次数

SKStoreProductViewController在iphone iOS 7横向应用程序上崩溃

我有一个通用的横向模式应用程序.SKStoreProductViewController在iPad上运行良好.但在iphone ios上崩溃7.甚至我将SKStoreProductViewController设置为在iPhone上的肖像上显示.

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
   if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
       NSLog(@"iphone portrait");
       return UIInterfaceOrientationPortrait;
   }
   else
       return [super preferredInterfaceOrientationForPresentation];
}
Run Code Online (Sandbox Code Playgroud)

SKStoreProductViewController在iOS 7的iphone上显示,但是当我旋转手机时,它会崩溃.我收到错误消息说:

*由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'终止应用程序,原因:'支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES'

谁知道如何解决这个问题?
谢谢

iphone objective-c ipad landscape-portrait ios7

4
推荐指数
1
解决办法
1751
查看次数