[英]Embedding a VFR Reader inside another view
I'm trying to add PDF viewing capability to my iPad app using the VFR Reader code. 我正在尝试使用VFR Reader代码将PDF查看功能添加到我的iPad应用程序中。
I can use the existing ReaderViewController to display Reader as a full screen page using code like: 我可以使用现有的ReaderViewController将Reader显示为全屏页面,使用如下代码:
ReaderDocument *document = [ReaderDocument withDocumentFilePath:file password:nil];
if (document != nil)
{
ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
// ...
[self presentModalViewController:readerViewController animated:YES];
}
which works very nicely indeed. 这确实非常好用。
However, I'd like to have other things around the PDF (such as a permanently display bar with buttons on along the top, for example), so ideally I'd like the Reader view inside a view of my own. 但是,我想在PDF周围有其他东西(比如一个带有按钮的永久显示栏,例如),所以理想情况下我喜欢读者视图在我自己的视图中。
I'm rather new to iOS programming and can't figure out how to go about achieving this. 我对iOS编程很陌生,无法弄清楚如何实现这一目标。 Could someone point me in the right direction and tell me what I need to do to have my own view with VFR Reader in a sub-view?
有人能指出我正确的方向并告诉我在子视图中用VFR阅读器自己查看需要做些什么吗?
I managed to figure out how to do this. 我设法弄清楚如何做到这一点。 Here's the solution for anyone who may be interested.
对于任何可能感兴趣的人来说,这是解决方案。
I created my container ViewController whose xib contained a UIView as a placeholder for the location of the PDF, then in its viewDidLoad method: 我创建了我的容器ViewController,其xib包含一个UIView作为PDF的位置的占位符,然后在其viewDidLoad方法中:
// Create the sub-ViewController, the VFR Reader ViewController
ReaderDocument *document = [ReaderDocument withDocumentFilePath:pdfFile password:nil];
_readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
// Pass on the required delegate for handling the close button
_readerViewController.delegate = self.delegate;
// Add the VFR Reader as a child
[self addChildViewController:_readerViewController];
[self.view addSubview:_readerViewController.view];
// Set the location of the VFR Reader to the same as the placeholder view
_readerViewController.view.frame = self.pdfPlaceholder.frame;
[_readerViewController didMoveToParentViewController:self];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.