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];
If I run on iOS7, everything works fine.
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.
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.
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?
Simply because
willRotateToInterfaceOrientation
is no more called in iOS8, it is deprecated.A similar question to yours can be found here
Citation of @mluisbrown :
I struggled a bit with some kind of a similar problem to yours. I tried following Apple recommendation to use
viewWillTransitionToSize
, which in my case did not solve my problem because this only gets triggered on changes from regular to compact for example an not on rotation.Which is detailed in apple documentation
Also a video of WWDC 2014 explains this but I can't remember which video it was. Perhaps the one on
What's new in Cocoa touch
or the one onView Controller Advancements in iOS 8
.EDIT
Note that in my case
viewWillTransitionToSize
, as explained, was not called because I wasn't changing from regular to compact so there was no size transition, strictly speaking for Apple.The only solution I fount was to handle this manually in the
viewDidLayoutSubviews
of the corresponding view controller.In my case I wanted to keep track of the top cell displayed in a tableview with autolayout. As it wasn't tracked automatically by the system, I had to check that manually and scroll manually to the adequate cell on rotation. That's why I did it that way. It's quite "heavy" but works in my case.
I would also be interested if anyone has an easier solution.
I finally managed to resolve my problem; here is what the issue was in case anyone else has the same problem.
My
ReaderViewController
was being presented from a class that had implementedviewWillTransitionToSize:withTransitionCoordinator:
, so the deprecated methods on child view controllers weren't being called.Also in that implementation it wasn't calling
and so the
viewWillTransitionToSize:withTransitionCoordinator:
method of all child view controllers wasn't being called either.The fix was to add a call to
into the parent VC's
viewWillTransitionToSize:withTransitionCoordinator:
method, subclassReaderViewController
, then add aviewWillTransitionToSize:withTransitionCoordinator:
to my subclass to call the appropriate methods inReaderViewController
.