Getting the size of a UIViewController view after rotation

I have a UIViewController with a bunch of subviews that I need to lay out in a different order if the iPad is in portrait or landscape mode. I would like to be able to capture the size that will be displayed in the UIViewController view after rotation so that I can calculate a new set of frames for my routines. However, I did not find a way to get this new size before the turn takes place, and by the time the turn takes place, it is too late, since I can’t revive the transition of the subzones to their new places.

Does anyone know about this?

+3
source share
2 answers

willAnimateRotationToInterfaceOrientation:duration:. :

interfaceOrientation . , , .

, .

+3

landscape portrait , :

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     if(((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || 
      (interfaceOrientation == UIInterfaceOrientationLandscapeRight))){

        self.view = landscape;

 }else if(((interfaceOrientation == UIInterfaceOrientationPortrait) || 
     (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))){

        self.view = portrait;

    }
    return YES;
}

, .

, [UIView beginAnimations:@"animation" context:nil]; [UIView commitAnimations]; .

+1

Source: https://habr.com/ru/post/1780072/


All Articles