在目标c中启动didload方法的LandscapeOrientation [英] LandscapeOrientation on start of didload method in objective c

查看:77
本文介绍了在目标c中启动didload方法的LandscapeOrientation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经制作了一个iPad应用程序,

I've made an iPad application,

我第一次以纵向模式加载应用程序时工作正常,但是当我以横向模式加载应用程序时这是第一次,它只采用纵向模式的坐标,因为在我的 didLoad 方法中,我只给出了纵向模式的坐标。

It works fine when I load my application in portrait mode for first time, but when I load my application in landscape mode for the first time, it takes the coordinates of portrait mode only, because inside my didLoad method I give coordinates of portrait mode only.

现在需要在我的 didLoad 方法中给出横向模式的坐标。

Now need to give coordinates of landscape mode inside my didLoad method.

我试过这个,在我的didLoad方法中

I tried this, inside my didLoad method

if (interfaceOrientation == UIInterfacePortraitmode ||
    interfaceOrientation == UIInterfaceUpsideDown)
{
    // do this....
}
else
{
    // do this....
}

但是我无法在我的<$里面写if / else的条件c $ c> didLoad 方法。

but I am unable to write the condition for the if/else inside my didLoad method.

我该怎么办?

推荐答案

-(void) viewWillAppear: (BOOL) animated {
       [super viewWillAppear: animated];
       [self adjustViewtForNewOrientation: self.interfaceOrientation];
}

-(void) willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation duration: (NSTimeInterval) duration {
       [self adjustViewtForNewOrientation: interfaceOrientation];
}


- (void) adjustViewtForNewOrientation: (UIInterfaceOrientation) orientation {
    if (UIInterfaceOrientationIsLandscape(orientation)) {
         // Do some stuff
    } else {
         // Do some other stuff
    }

也可以在ViewDidLaod()方法中调用 adjustViewtForNewOrientation

also call adjustViewtForNewOrientation in your ViewDidLaod() method,

这篇关于在目标c中启动didload方法的LandscapeOrientation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆