LandscapeOrientation on start of didload method in objective c

前端 未结 3 1331
粉色の甜心
粉色の甜心 2021-01-13 23:34

I\'ve made an iPad application,

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 fi

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-13 23:58

    You can do handling as below -

    -(void) viewWillAppear: (BOOL) animated {
           [super viewWillAppear: animated];
           [self updateLayoutForNewOrientation: self.interfaceOrientation];
    }
    
    -(void) willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation duration: (NSTimeInterval) duration {
           [self updateLayoutForNewOrientation: interfaceOrientation];
    }
    

    and then finally custom method -

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

    }

提交回复
热议问题