0

カスタム ビデオ カメラを使用しています。録画を簡単にするために、カメラとそのオーバーレイをポートレートに設定しますが、ランドスケープのように見えます。プロジェクトの性質上、ビデオの幅を長くしたいので、これは私にとってはうまくいきます。現在、私はiOS 6でビューコントローラーを縦向きに回転させ、デバイスがlandscapeLeftとlandscapeRightに回転したときにportraitUpsideDownを取得するという課題を抱えています。デバイスが横向きに回転するときにView Controllerに縦向きに回転するようにiOS 6に指示する方法はありますか? 以前は shouldAutoRotateToOrientation でこれを行っていました

現在、私はこれらの方法をいじっています

- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientationsForWindow {
    return UIInterfaceOrientationMaskPortrait;
}

iOS6 でのこれらの変更に関するスタック オーバーフローに関する他の多くのドキュメントを見てきましたが、この問題の解決策はまだ見つかっていません。

4

1 に答える 1

0

私たちは仕事をすることができました。ランドスケープ用に行いましたが、次のコードを変更することでポートレート用に行うことができます。

インターフェイスの最初の部分 (これは会社のポリシーの一部であり、すべてを表示することはできません):

@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; 
}
于 2012-11-30T08:52:21.270 に答える