如何在目标C中添加QLPreviewController作为Subview [英] How to add QLPreviewController as Subview in objective C

查看:116
本文介绍了如何在目标C中添加QLPreviewController作为Subview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将QLPreviewController添加到UIView作为子视图。

Is it possible to add QLPreviewController to UIView as sub view.

我试过这样

[self.view addSubview:previewViewController.view] 

我也叫过 reloadData

[previewViewController reloadData];

我查看此网址添加QLPreviewController作为子视图不会加载PDF 。但是我不明白什么是 self.pdfPreviewView

I check with this URL Adding QLPreviewController as subview doesn't load PDF . But I did not understand what is self.pdfPreviewView

请指导我如何将QLPreviewController添加为子视图。 。

Please guide me how I can add QLPreviewController as sub view..

推荐答案

是的,可以参考下面的代码:

Yes its possible, see the code below:

QLPreviewController* preview = [[QLPreviewController alloc] init];
preview.dataSource = self;
preview.delegate = self;
[self addChildViewController:preview];//*view controller containment
//set the frame from the parent view
CGFloat w= self.quickLookView.frame.size.width; 
CGFloat h= self.quickLookView.frame.size.height;
preview.view.frame = CGRectMake(0, 0,w, h);
[self.quickLookView addSubview:preview.view];    
[preview didMoveToParentViewController:self];
//save a reference to the preview controller in an ivar
self.previewController = preview;

这篇关于如何在目标C中添加QLPreviewController作为Subview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆