嗨,我使用此代码在 iPhone 6 上支持 splitViewController:
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
self.forcedTraitCollection = nil;
if (size.height == 320.0 || size.width == 320.0)
{
self.forcedTraitCollection = nil;
}
else
{
self.forcedTraitCollection = [UITraitCollection traitCollectionWithHorizontalSizeClass:UIUserInterfaceSizeClassRegular];
}
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
问题是返回的大小是错误的 - 它为所有模拟器返回 CGSize(320,568)。+n 它返回宽度作为高度,反之亦然。
谢谢