The UIDocumentInteractionController
seems to have trouble interacting properly with the new iOS 7 status bar particularly in landscape orientation. The code I have for displaying the viewer right now:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"example" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:filePath];
UIDocumentInteractionController *pdfViewer = [UIDocumentInteractionController interactionControllerWithURL:url];
[pdfViewer setDelegate:self];
[pdfViewer presentPreviewAnimated:YES];
}
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
return self;
}
- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller
{
return self.view;
}
When the interaction controller first appears the status bar overlaps the title.
Rotating to landscape on the other side fixes the behaviour temporarily.
As expected tapping on the document itself allows dismisses the frame. However once the document is tapped once more to activate the frame the overlap occurs again as with the first image.
I have tried setting documentInteractionControllerRectForPreview
to no avail.
- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller
{
return CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height);
}
I do not wish to hide the status bar when the interaction controller comes up and I assume it is possible to do this correctly since the Mail app behaves correctly and it looks like it is using the same class.
A minimal example project attached for anyone who wants to play with the code: https://hostr.co/PiluL1VSToVt