简体   繁体   English

横向模式在iOS 8中是错误的-Xcode 6

[英]Landscape mode is wrong in iOS 8 - Xcode 6

I've tried the following code to my landscpae ipad application and it works fine ...but know in xcode6 it appears wrong (see the print screen) 我已经在我的landscpae ipad应用程序中尝试了以下代码,并且可以正常工作...但是知道在xcode6中它似乎是错误的(请参见打印屏幕)

    [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;

    self.window.rootViewController = self.loginRegisterView;
    CGAffineTransform rotate = CGAffineTransformMakeRotation(1.57079633);
    [self.window setTransform:rotate];

    CGRect contentRect = CGRectMake(0, 0, 1024, 768);
    self.window.bounds = contentRect;
    [self.window makeKeyAndVisible];

and when I launch the app appears: https://imageshack.com/i/kqo1EBgAp 当我启动该应用程序时出现: https : //imageshack.com/i/kqo1EBgAp

EDIT: 编辑:

Now, I don't rotate the window manually...only in General Tab, like the print screen 现在,我不再手动旋转窗口...仅在常规选项卡中,例如打印屏幕

https://imageshack.com/i/idzqoTZQp https://imageshack.com/i/idzqoTZQp

And here is the xib file 这是XIB文件

https://imageshack.com/i/ipB1cOpGp https://imageshack.com/i/ipB1cOpGp

and here how it appears on device 以及它在设备上的显示方式

https://imageshack.com/i/eyioC4PCp https://imageshack.com/i/eyioC4PCp

The issue seems to be the order of calls when you set up the window in your app delegate. 当您在应用程序委托中设置窗口时,问题似乎是调用的顺序。 You need to call makeKeyAndVisible before you assign the rootViewController . 在分配makeKeyAndVisible之前,需要调用rootViewController The following works: 以下作品:

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
[self.window makeKeyAndVisible];
self.window.rootViewController = self.myMainViewController;

But if you change the order to: 但是,如果您将顺序更改为:

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.rootViewController = self.myMainViewController;
[self.window makeKeyAndVisible];

You get the behavior you are experiencing. 您得到您正在遇到的行为。

I added the following code in viewDidLoad 我在viewDidLoad中添加了以下代码

  - (void)viewDidLoad
{
    CGAffineTransform rotate = CGAffineTransformMakeRotation(M_PI/2);
    [self.view setTransform:rotate];
    [self.view setFrame:CGRectMake(0, 0, 768, 1024)];
    [super viewDidLoad];
      // Do any additional setup after loading the view.
}

EDIT: 编辑:

If add in 如果添加

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions it works for all the views


    CGAffineTransform rotate = CGAffineTransformMakeRotation(M_PI/2);
    [self.window setTransform:rotate];
    [self.window setFrame:CGRectMake(0, 0, 768, 1024)];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM