UIDocumentInteractionController
似乎無法正確與新的iOS 7狀態欄進行交互,特別是在橫向模式下。我現在用於顯示查看器的代碼:具有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
它是iOS 7中的錯誤嗎?有新的解決方案嗎?我用相同的方式來解決問題,但它在我的應用程序中造成了另一個錯誤。 – GxocT