加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – 如何将QLPreviewController添加为目标C中的子视

发布时间:2020-12-16 05:21:29 所属栏目:百科 来源:网络整理
导读:可以将QLPreviewController添加到UIView作为子视图. 我试过这样 [self.view addSubview:previewViewController.view] 我也叫reloadData [previewViewController reloadData]; 我检查这个URL Adding QLPreviewController as subview doesn’t load PDF.但我不
可以将QLPreviewController添加到UIView作为子视图.

我试过这样

[self.view addSubview:previewViewController.view]

我也叫reloadData

[previewViewController reloadData];

我检查这个URL Adding QLPreviewController as subview doesn’t load PDF.但我不明白是什么是self.pdfPreviewView

请指导我如何添加QLPreviewController作为子视图..

解决方法

是可能的,请看下面的代码:
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,w,h);
[self.quickLookView addSubview:preview.view];    
[preview didMoveToParentViewController:self];
//save a reference to the preview controller in an ivar
self.previewController = preview;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读