Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add pdf to UIView, not pushViewController? #101

Open
aloveric opened this issue Oct 30, 2018 · 2 comments
Open

How to add pdf to UIView, not pushViewController? #101

aloveric opened this issue Oct 30, 2018 · 2 comments

Comments

@aloveric
Copy link

No description provided.

@Y2JChamp
Copy link

Y2JChamp commented Nov 8, 2018

this is my snippet:
`let remotePDFDocumentURLPath = item.url
let remotePDFDocumentURL = URL(string: remotePDFDocumentURLPath!)!
let document = PDFDocument(url: remotePDFDocumentURL)!

    let readerController = PDFViewController.createNew(with: document)
    
    let modalReaderController: PDFReaderViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "pdfreadercontroller") as! PDFReaderViewController
    present(modalReaderController, animated: true, completion: nil)
    modalReaderController.containerView.addSubview(readerController.view)
    modalReaderController.addChildViewController(readerController)
    
    readerController.view.translatesAutoresizingMaskIntoConstraints = false
    
    let top = NSLayoutConstraint(item: readerController.view, attribute: .top, relatedBy: .equal, toItem: modalReaderController.containerView, attribute: .top, multiplier: 1, constant: 0)
    let bottom = NSLayoutConstraint(item: readerController.view, attribute: .bottom, relatedBy: .equal, toItem: modalReaderController.containerView, attribute: .bottom, multiplier: 1, constant: 0)
    let leading = NSLayoutConstraint(item: readerController.view, attribute: .leading, relatedBy: .equal, toItem: modalReaderController.containerView, attribute: .leading, multiplier: 1, constant: 0)
    let trailing = NSLayoutConstraint(item: readerController.view, attribute: .trailing, relatedBy: .equal, toItem: modalReaderController.containerView, attribute: .trailing, multiplier: 1, constant: 0)
    modalReaderController.containerView.addConstraints([top, bottom, leading, trailing])`

@aloveric
Copy link
Author

@Y2JChamp Thanks~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants