微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

可以将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;

原文地址:https://www.jb51.cc/c/114905.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐