-1

I got wrong width and height when rotate screen. It works in iOS 15;

[UIScreen mainScreen].bounds.width will return the height.

[UIScreen mainScreen].bounds.height will return the width.

They exchanged values

I try to use "setNeedsUpdateOfSupportedInterfaceOrientations" but failed.

Is there any solution to solve the issue?

frankAlx
  • 1
  • 1

1 Answers1

0

you should consider using viewWillTransition function instead:

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];

    // Your other code ... 
    // reAssign values to height and width variable here when rotated
}
Vikas Saini
  • 483
  • 4
  • 16