UIDocumentInteractionController
特に横向きの場合、新しい iOS 7 ステータス バーとの適切なやり取りに問題があるようです。今ビューアを表示するためのコード:
- (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;
}
インタラクション コントローラーが最初に表示されると、ステータス バーがタイトルに重なって表示されます。
反対側で横向きに回転すると、動作が一時的に修正されます。
予想どおり、ドキュメント自体をタップすると、フレームを閉じることができます。ただし、ドキュメントをもう一度タップしてフレームをアクティブにすると、最初の画像と同様にオーバーラップが再び発生します。
私はdocumentInteractionControllerRectForPreview
無駄に設定しようとしました。
- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller
{
return CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height);
}
インタラクション コントローラーが起動したときにステータス バーを非表示にしたくありません。メール アプリは正しく動作し、同じクラスを使用しているように見えるため、これを正しく行うことができると思います。
コードで遊んでみたい人のために添付された最小限のサンプル プロジェクト: https://hostr.co/PiluL1VSToVt