Ios6 在iOS 6中处于设备横向时将UIViewController旋转为纵向

Ios6 在iOS 6中处于设备横向时将UIViewController旋转为纵向,ios6,modalviewcontroller,deprecated,Ios6,Modalviewcontroller,Deprecated,我正在使用一台定制的摄像机。为了便于录制,我将相机的覆盖设置为纵向,但看起来好像是横向的。这对我来说是可行的,因为我希望由于项目的性质,视频拍摄的宽度要长。目前,我在iOS 6上遇到了一个挑战,当设备旋转到landscapeLeft和landscapeRight时,如何让我的视图控制器旋转到纵向和纵向。在iOS 6中,当设备旋转到横向时,是否仍然可以告诉视图控制器旋转到纵向?以前我会用shouldAutoRotateToOrientation做这个 目前我正在玩弄这些方法 - (BOOL)sho

我正在使用一台定制的摄像机。为了便于录制,我将相机的覆盖设置为纵向,但看起来好像是横向的。这对我来说是可行的,因为我希望由于项目的性质,视频拍摄的宽度要长。目前,我在iOS 6上遇到了一个挑战,当设备旋转到landscapeLeft和landscapeRight时,如何让我的视图控制器旋转到纵向和纵向。在iOS 6中,当设备旋转到横向时,是否仍然可以告诉视图控制器旋转到纵向?以前我会用shouldAutoRotateToOrientation做这个

目前我正在玩弄这些方法

- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientationsForWindow {
    return UIInterfaceOrientationMaskPortrait;
}

我已经阅读了许多关于iOS6中这些更改的堆栈溢出的其他文档,但尚未找到解决此问题的方法。

我们能够开始工作。我们为横向设计了,但您可以通过修改下面的代码来为纵向设计:

首先在界面中(这只是公司政策的部分b/c,我不能全部显示):

@interface YourViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
    UITableView *myTableView;
    CGAffineTransform _originalTransform;
    CGRect _originalBounds;
    CGPoint _originalCenter;
}

@property (nonatomic, retain) UITableView *myTableView;

@end
@implementation YourViewController

@synthesize myTableView;

- (void)loadView {

    UIView *viewContainer = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

    CGRect tableFrame;
    tableFrame.origin.x += 10;
    tableFrame.origin.y -= 15;
    tableFrame.size.height = 320;
    tableFrame.size.width = 460;

    // create and configure the table view
    myTableView = [[UITableView alloc] initWithFrame:tableFrame style:UITableViewStylePlain];

    myTableView.delegate = self;
    myTableView.dataSource = self;
    myTableView.autoresizesSubviews = YES;
    myTableView.scrollEnabled = YES;    
    myTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;


    [viewContainer addSubview:myTableView];
    self.view = viewContainer;  
}

- (void)viewWillAppear:(BOOL)animated {

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

    _originalTransform = [[appDelegate navController].view transform];
    _originalBounds = [[appDelegate navController].view bounds];
    _originalCenter = [[appDelegate navController].view center];

    CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(3.14/2));
    //landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +80.0, +100.0);

    [[appDelegate navController].view setTransform:landscapeTransform];

    [appDelegate navController].view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [appDelegate navController].view.bounds  = CGRectMake(0.0, 0.0, 480.0, 320.0);
    //[appDelegate navController].view.center  = CGPointMake (240.0, 160.0);

    [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
}

- (void) viewWillDisappear:(BOOL)animated {

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    [[appDelegate navController].view setTransform:_originalTransform];
    [[appDelegate navController].view setBounds:_originalBounds];
    [[appDelegate navController].view setCenter:_originalCenter];

    [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait; 
}