0

我的应用程序是仅纵向应用程序。我需要在横向模式下添加一个子视图。对于要添加的新视图,我在 iOS 6 中设置了以下方向。

-(NSUInteger)supportedInterfaceOrientations
{
    NSUInteger options = UIInterfaceOrientationMaskAll;

    if (self.inAppBrowserOrientation)
     {
        if (self.inAppBrowserOrientation == UIInterfaceOrientationLandscapeLeft || self.inAppBrowserOrientation == UIInterfaceOrientationLandscapeRight)
        options = UIInterfaceOrientationMaskLandscape;
        return options;
    }
}

视图将以纵向模式添加。在方向上,此视图将仅在横向模式下旋转,这是预期的。

第一次添加视图,为什么要在纵向模式下添加?虽然self.inAppBrowserOrientationUIInterfaceOrientationLandscapeRight

4

2 回答 2

2

尝试使用以下代码段

-(NSUInteger)supportedInterfaceOrientations
{
    NSUInteger options = UIInterfaceOrientationMaskAll;

    if (self.inAppBrowserOrientation)
     {
        if (self.inAppBrowserOrientation == UIInterfaceOrientationLandscapeLeft || self.inAppBrowserOrientation == UIInterfaceOrientationLandscapeRight)
        options = UIInterfaceOrientationMaskLandscape;
        return options;
    }
    else
    {
        return UIInterfaceOrientationMaskLandscape;
    }

}

我不确定,但当您第一次加载 aqpp 时,这可能是个问题

享受编程!!

于 2013-03-19T13:05:42.493 回答
2
- (void)viewDidAppear:(BOOL)animated
{ 
    [super viewDidAppear:animated];

    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
    CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(270));
    landscapeTransform = CGAffineTransformTranslate (landscapeTransform, 0.0, 0.0);
    [[self navigationController].view setTransform:landscapeTransform];
    self.navigationController.view.bounds = CGRectMake(0.0, 0.0, 480, 320);
    self.navigationController.navigationBar.frame = CGRectMake(0.0, 20.0, 480, 44.0);


} 

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];   

    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
    CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(0));
    landscapeTransform = CGAffineTransformTranslate (landscapeTransform, 0.0, 0.0);
    [[self navigationController].view setTransform:landscapeTransform];
    self.navigationController.view.bounds = CGRectMake(0.0, 0.0, 320, 480);
    self.navigationController.navigationBar.frame = CGRectMake(0.0, 20.0, 320.0, 44.0);

}

在这里,默认方向是纵向,但是当编译器转到 viewDidAppear 时,它将旋转 270 度,因此在横向模式下.. 相应地调整帧大小...

祝你好运 !!

于 2013-03-19T13:26:14.710 回答