在iOS8上没有调用willRotateToInterfaceOrientation [英] willRotateToInterfaceOrientation not called on iOS8

查看:731
本文介绍了在iOS8上没有调用willRotateToInterfaceOrientation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的应用中使用 VFR PDF查看器库,因此我将其呈现:

I'm using the VFR PDF viewer library in my app, where I present it thus:

ReaderDocument *document = [ReaderDocument withDocumentFilePath:pdfFile password:nil];
ReaderViewController *vc = [[ReaderViewController alloc] initWithReaderDocument:document];
[self.navigationController pushViewController:vc animated:YES];

如果我在iOS7上运行,一切正常。

If I run on iOS7, everything works fine.

如果我在iOS8上运行我的应用程序,则不会调用ReaderViewController中的willRotateToInterfaceOrientation方法,因此当旋转设备时,文档无法正确重新格式化。

If I run my app on iOS8, the willRotateToInterfaceOrientation method in ReaderViewController never gets called, so when the device is rotated the document doesn't get reformatted correctly.

但是,如果我运行iOS8上的库附带的演示应用程序,那么ReaderViewController中的willRotateToInterfaceOrientation会被调用,这让我相信库是正常的,我做错了(或忽略了做某事)我的应用。

However, if I run the demo app that comes with the library on iOS8, the willRotateToInterfaceOrientation in ReaderViewController does get called, which leads me to believe the library is ok, and I'm doing something wrong (or neglecting to do something) in my app.

我对这种行为感到很困惑。为什么不在我的iOS8应用程序中调用rpmRotateToInterfaceOrientation,但它在其他变体下呢?我怎样才能尝试追踪这个?

I'm rather puzzled at this behaviour. Why doesn't willRotateToInterfaceOrientation get called in my app on iOS8, but it does under the other variations? How can I try to track this down?

推荐答案

我终于设法解决了我的问题;这是问题,以防其他人有同样的问题。

I finally managed to resolve my problem; here is what the issue was in case anyone else has the same problem.

我的 ReaderViewController 是从一个已实现 viewWillTransitionToSize:withTransitionCoordinator:的类,因此未调用子视图控制器上已弃用的方法。

My ReaderViewController was being presented from a class that had implemented viewWillTransitionToSize:withTransitionCoordinator:, so the deprecated methods on child view controllers weren't being called.

同样在该实现中它没有调用

Also in that implementation it wasn't calling

[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]

所以所有子视图控制器的 viewWillTransitionToSize:withTransitionCoordinator:方法都没有'被调用。

and so the viewWillTransitionToSize:withTransitionCoordinator: method of all child view controllers wasn't being called either.

解决方法是添加一个电话

The fix was to add a call to

[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]

进入父VC的 viewWillTransitionToSize:withTransitionCoordinator:方法,子类 ReaderViewController ,然后添加一个 viewWillTransitionToSize:withTransitionCoordinator:到我的子类中调用 ReaderViewController 中的相应方法。

into the parent VC's viewWillTransitionToSize:withTransitionCoordinator: method, subclass ReaderViewController, then add a viewWillTransitionToSize:withTransitionCoordinator: to my subclass to call the appropriate methods in ReaderViewController.

这篇关于在iOS8上没有调用willRotateToInterfaceOrientation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆