Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

willRotateToInterfaceOrientation not called on iOS8

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?

like image 338
Dave W Avatar asked Nov 10 '14 10:11

Dave W


People also ask

Why wont my iOS screen rotate?

Swipe down from the top right-hand corner of your screen to open Control Centre. Tap the Portrait Orientation Lock button to make sure that it's turned off.

How do I force an app to rotate on iOS?

iOS Settings and (lack of) Apps To find the setting in iOS 11, you will need to swipe up from the bottom of the screen and open the Control Center. Locate the Rotation Lock icon that looks like a lock, with an arrow circling it in a clockwise direction.

Does Safari support screen rotation?

The screen on your iPad can rotate so that you can see apps like Safari and Messages in portrait or landscape mode.


1 Answers

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 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]

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]

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.

like image 187
Dave W Avatar answered Nov 06 '22 05:11

Dave W