相关疑难解决方法(0)

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

由于ShouldAutorotateToInterfaceOrientation在iOS 6中已弃用并且我使用它来强制特定视图仅限纵向,在iOS 6中执行此操作的正确方法是什么?这仅适用于我的应用的一个区域,所有其他视图都可以旋转.

xcode xamarin.ios ios ios6

85
推荐指数
6
解决办法
10万
查看次数

shouldAutorotateToInterfaceOrientation未在iOS 6中调用

我正在使用MGSplitViewController,我shouldAutorotateToInterfaceOrientation用来控制旋转时主视图控制器的大小.

它在iOS 5上运行良好,但在iOS 6(模拟器和iPad)shouldAutorotateToInterfaceOrientation上从未调用过.

这是一个我应该期望在iOS 6的最终版本中修复的错误或者我不知道已经改变的东西吗?

orientation ios ios6

61
推荐指数
8
解决办法
9万
查看次数

应用程序仅对Portrait启用,但UIImagePickerController在iOS6中旋转

请注意以下答案 - 不适用于iOS6,所以我仍然需要一个答案!

我的应用程序仅在纵向模式下启用.

但是,如果我将UIImagePickerController作为子视图嵌入并旋转设备,则顶部和底部栏位于同一位置,但UIImagePickerController会旋转.

如何防止它旋转?

这是代码:

    [self.view.window addSubview:self.imagePickerController.view];
    self.imagePickerController.showsCameraControls = NO; 
    self.imagePickerController.view.frame = CGRectMake(0, 90, 320, 320);
    self.imagePickerController.allowsEditing = NO;
Run Code Online (Sandbox Code Playgroud)

EDITED

我正在使用iOS6,其中shouldAutorotate不会被调用

iphone cocoa-touch objective-c uiimagepickercontroller ios

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

如何在应用程序部署信息纵向锁定时手动设置设备方向?

我不希望我的应用程序被美化,并始终是porttrait.So我使我的应用程序部署信息只设置肖像.但是当我需要在我的应用程序中显示任何图像或视频时,我需要横向模式以便更好地显示.

我可以通过检测设备方向的变化

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(orientationChanged:)
 name:UIDeviceOrientationDidChangeNotification
 object:[UIDevice currentDevice]];

- (void) orientationChanged:(NSNotification *)note
{
UIDevice * device = note.object;
switch(device.orientation)
{
    case UIDeviceOrientationPortrait:
        /*  */
        break;

    case UIDeviceOrientationPortraitUpsideDown:
        /*  */
        break;
    case UIDeviceOrientationLandscapeLeft:
       /*  */
       break;

    case UIDeviceOrientationLandscapeRight:
       /*  */
       break;
    default:
        break;
};
}
Run Code Online (Sandbox Code Playgroud)

但是,即使应用程序部署信息纵向被锁定,如何手动更改设备方向?

不起作用

NSNumber *value=[NSNumber numberWithInt: UIDeviceOrientationLandscapeLeft];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"]; 
Run Code Online (Sandbox Code Playgroud)

iphone portrait ios landscape-portrait uideviceorientation

5
推荐指数
2
解决办法
9832
查看次数