首页 文章

iPad横向定位

提问于
浏览
0

我正在为iPad创建纵向和横向模式的应用程序 . 我在横向模式下为iPad创建了一个XIB,但是当我运行该应用程序时,它总是以纵向模式显示 . 我将属性列表(.plist)文件下的所有设置设置为“支持的界面方向(iPad)”并设置横向(左主页按钮)和横向(右主页按钮),并检查代码中的方向但所有这些都没有工作 . 请帮助我们,如果有人知道确切的问题或这个,我们正在使用导航控制器

1 回答

  • 0

    在委托中的didFinishLaunchingWithOptions中添加这行代码 .

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(preferredInterfaceOrientationForPresentation) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
    

    然后在委托中首先添加以下方法并运行应用程序,如果已修复,COOOOL会在每个视图控制器中添加以下四种方法 . 你的问题将得到解决 .

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    
        return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    }
    
    - (BOOL)shouldAutorotate {
    
        return NO;
    }
    
    - (NSUInteger)supportedInterfaceOrientations {
    
        return UIInterfaceOrientationMaskLandscape;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    
        return UIInterfaceOrientationLandscapeLeft;
    }
    

相关问题