In the iOS16 system, when the horizontal and vertical screen rotation occurs, at some point, interfaceOrientation=landspace, [UIScreen mainScreen].bounds, UIWindowScene.screen.bounds.size, keyWindow.bounds.size exception will occur
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *ws = (UIWindowScene *)array[0];
NSLog(@"interfaceOrientation:%d",ws.interfaceOrientation);
NSLog(@"screen:%@,screen:%@,keywindow:%@",NSStringFromCGSize(ws.screen.bounds.size),NSStringFromCGSize([UIScreen mainScreen].bounds.size),NSStringFromCGSize(ws.keyWindow.bounds.size));
---------out
2022-08-25 16:32:04.536120+0800 app[2008:61285] interfaceOrientation:3
2022-08-25 16:32:04.536305+0800 app[2008:61285] screen:{375, 812},screen:{375, 812},keywindow:{812, 375}
(lldb)
The orientation is landscape, but [UIScreen mainScreen].bounds or UIWindowScene.screen.bounds.size is the value in the portrait state, and the value of keyWindow.bounds.size is the value in the landscape state.