[英]UIViewController device rotation delegate methods are not getting called in iOS8
I have been working an iOS 7 app to make it compatible for ios 8 (beta 5). 我一直在使用iOS 7应用程序,使其兼容ios 8(beta 5)。 In this application, UIViewController
( vc1
) presents another UIViewController
( vc2
). 在这个应用程序中, UIViewController
( vc1
)呈现另一个UIViewController
( vc2
)。 vc1
supports both Portrait and Landscape orientations; vc1
支持纵向和横向方向; vc2
supports only Portrait orientation. vc2
仅支持纵向方向。 When vc2
is presented, it asks vc1
: shouldAutorotateToInterfaceOrientation:
and this returns YES
. 当vc2
提出,它要求vc1
: shouldAutorotateToInterfaceOrientation:
这将返回YES
。
In iOS8 (Beta 5) willRotateToInterfaceOrientation:
and didRotateFromInterfaceOrientation:
are not getting called as well as the new iOS 8 API method viewWillTransitionToSize
. 在iOS8(Beta 5)中, willRotateToInterfaceOrientation:
和didRotateFromInterfaceOrientation:
没有被调用以及新的iOS 8 API方法viewWillTransitionToSize
。 But, this works fine in iOS7. 但是,这在iOS7中运行良好。
I know willAnimateRotationToInterfaceOrientation
and didRotateFromInterfaceOrientation
are deprecated in iOS 8, but even iOS 8 delegate methods are not getting called. 我知道willAnimateRotationToInterfaceOrientation
和didRotateFromInterfaceOrientation
在iOS 8中已被弃用,但即使iOS 8委托方法也没有被调用。 Every time when launched vc2
from vc1
always screens loads in portrait mode only even though I mentioned supported interface orientation as landscape left. 每次从vc1
启动vc2
,始终只在纵向模式下屏幕加载,即使我提到支持的界面方向为横向左侧。
Any ideas... is it a bug in iOS8? 任何想法......这是iOS8中的一个错误吗?
Well, I didn't figure out your problem best but as soon I have a bunch of lines working fine with rotation in iOS 8.1 I will present them to you. 好吧,我没有最好地解决你的问题,但是我很快就会在iOS 8.1中使用旋转工作,我会将它们呈现给你。 They are just taken and a little bit of edited from the Apple API Reference. 它们刚刚从Apple API Reference中进行了一些编辑。
Simply I put this in every VC and i just edit the code when needed. 我只需将它放在每个VC中,我只需在需要时编辑代码。 For example I have an app that have initial view controller in portrait and then VC changes ( segue is done ) to a LandscapeVC with different features. 例如,我有一个应用程序,它具有纵向初始视图控制器,然后VC更改(segue已完成)到具有不同功能的LandscapeVC。 This is the portrait view methods leading to a rotation in LandscapeView. 这是导致在LandscapeView中旋转的纵向视图方法。
bool isShowingLandscapeView = false;
- (void)awakeFromNib
{
isShowingLandscapeView = NO;
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
}
- (void)orientationChanged:(NSNotification *)notification
{
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
if (UIDeviceOrientationIsLandscape(deviceOrientation) &&
!isShowingLandscapeView)
{
isShowingLandscapeView = YES;
[self performSegueWithIdentifier:@"toLandscape" sender:self];
}
I hope I made it simple for understanding. 我希望我理解简单。 Don't hesitate to improve my answer, we all learn in this life ! 不要犹豫,改善我的答案,我们这辈子都在学习!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.