2014-11-05 74 views
3

在之前的iOS版本中,我曾經將QLPreviewController添加爲子視圖。使用我自己的應用程序標題和導航欄非常方便,但在iOS 8中,它在標題下方添加了一個空白區域。這是它自己的導航欄的空間。如何在目標C中添加QLPreviewController作爲子視圖 - iOS8

你可以看到所附IMG:screenshot which shows the white bar

我用這個代碼:

QLPreviewController *previewController = [[QLPreviewController alloc] init]; 
previewController.dataSource = self; 
previewController.delegate = self; 
previewController.currentPreviewItemIndex = 0; 
previewController.view.frame = CGRectMake(0, 0, self.containerView.frame.size.width, self.containerView.frame.size.height); 
[self addChildViewController:previewController]; 
[previewController didMoveToParentViewController:self]; 
[self.containerView addSubview:previewController.view]; 

我如何十個分量的iOS7的funcionality?我只想隱藏qlpreviewcontroller導航欄

感謝

回答

0

我解決完全相同的問題。我迄今發現的唯一的解決辦法是:

// qlController.view.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds));//self.view.bounds; 
// qlController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 

[self addChildViewController:qlController]; 
[self.view addSubview:qlController.view]; 

NSDictionary *bindings = @{@"qlPreviewController": qlController.view}; 
qlController.view.translatesAutoresizingMaskIntoConstraints = NO; 
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[qlPreviewController]|" options:0 metrics:nil views:bindings]]; 
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[qlPreviewController]|" options:0 metrics:nil views:bindings]]; 

[qlController didMoveToParentViewController:self]; 

註釋行是遺留代碼,完美地工作在iOs7。主要想法是停止使用彈簧和支柱,並開始使用自動佈局。結果看起來不錯,但旋轉仍然存在一些問題。

做工不錯: iPhone 4S的/ 5/6/6 + iOs7縱向+橫向,縱向iOS8上iPad的 所有車型iOs7,8縱向+橫向

作品不好: iPhone 4S的/ 5/6/6 + iOs8橫向:navBar和內容之間有一定的間距。我認爲這是Apple的QLPreviewController而不是我的代碼的問題。

+0

最後我用一個UIWebView作爲解決方法。我不喜歡它,但它適用於所有版本。除了我的應用程序不能使用自動佈局,它支持iOS 5.1.1的舊iPad – buttcmd 2014-11-10 19:26:33

相關問題