3

In previous iOS versions I used to add the QLPreviewController as a subview. It is very handy to use my own app headers and navigation bar but in iOS 8 it adds a white space just below the header. It is the space for its own navigator bar.

You can see the attached img: screenshot which shows the white bar

I use this code:

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

How can i mantain the iOS7 funcionality? I only want to hide the qlpreviewcontroller navigationbar

Thanks

buttcmd
  • 641
  • 5
  • 14

1 Answers1

0

I'm solving the EXACT same problem. The only solution I found so far is the following:

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

Commented lines are legacy code, that worked perfectly on iOs7. The main idea is stop using spring and struts and start using auto layout. Results looks good enough, but still there are some problems with rotations.

Works good: Iphone 4s/5/6/6+ iOs7 portrait + landscape, iOs8 portrait IPad all models iOs7,8 portrait + landscape

Works bad: Iphone 4s/5/6/6+ iOs8 landscape : has some spacing between navBar and content. I think it is problem with Apple's QLPreviewController rather than my code.

Nikita Took
  • 3,980
  • 25
  • 33
  • Finally i used as a workaround a UIWebView. I don't like it but it works with all versions. Besides my app can't use autolayout it supports old iPads with iOS 5.1.1 – buttcmd Nov 10 '14 at 19:26