ios - 2 个 View Controller 合二为一( Collection View ?)

标签 ios swift pdf uiviewcontroller uicollectionview

我有这个问题:我需要打开一个 PDF 文档并在显示屏底部显示我的几个元素(按钮、文本字段)。 PDF 文档以任何 View Controller 打开:

let document = PDFDocument(url: remotePDFDocumentURL)!
let readerController = PDFViewController.createNew(with: document)
navigationController?.pushViewController(readerController, animated: true)

我首先想到的是使用 Collection View 。但是还没有结果,因为PDF文档是动态创建的。老实说,我以前没有使用过 CV。 可能有一种不太正确的方法 - 只需将元素添加到创建的 (PDF) View Controller 中,然后将所有元素移高一点。

提示正确的决定,谢谢!

最佳答案

我建议如下(只是伪代码,因为我目前没有可用的 Xcode):

  • 创建你自己的 View Controller ,我们称之为ContainerViewController
  • 将您的自定义控件添加到其中
  • 为 PDF 添加一个占位符 View (带导出)
  • 随心所欲地布局
  • PDFViewController View 作为 subview 添加到容器中;布置好
  • (如果需要:使 PDFViewController 可从您的容器访问)
  • 完成 view container containment容器 View Controller 中的要求
  • 将容器推送到导航 Controller 上

关于ios - 2 个 View Controller 合二为一( Collection View ?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45952166/

相关文章:

ios - 存储具有通用类型的闭包

uiwebview - Swift UIWebView 可选值为 nil

python - Matplotlib 输出为 PDF 用于 Corel Draw

pdf - Ghostscript 9.18 (gswin64c.exe) 在 -dNumRenderingThreads > 1 时崩溃

ios - 如何使用雅虎!在 iOS 应用程序中联系 api?

ios - Swift SpriteKit PhysicsBody 被 Xcode 强制为可选

ruby - 使用 Swift,如何使用 SHA1 创建 OpenSSL HMAC 摘要,然后使用严格的encode64 进行编码

pdf - 如何在旋转的 PDF 中旋转文本和图像?

iOS NSURLConnection 不从某些 URL 下载文件

ios - 如何在 Swift 中解析更新 CSV 文件值?