ScrollView Content Disappears
Hello there, I have an issue that after I render a scrollView to PDF the buttons on my tool bar are not usable and if the device is rotated then the scrollview content disappears off screen. I have tried many methods to stop this and no luck so far. Please advise how I can resume the view to the original state after PDF generation? Thank you for your help.
Any Help? I'm getting the same issue.
Any update on this?
Hi @ltblueberry0 , I got a work around.
1-Create a xib looking like your scrollview. But without scrollview :) 2-genereate a pdf using your xib.
@jeremiasdsa Thank you for the quick reply! Did you also figure out how to create a multi-page PDF from a UIScrollView?
@ltblueberry0 I did something like that:
on my xib file I got 2 views. Now you can use let page1 = PDFPage.View(view1) let page2 = PDFPage.View(view2) let pages = [page1, page2, ... ] and use pages to generate your PDF multi-page

So, now you are using a View( xib [view1,view2] ) that is not showing on your screen, and it wont messing you scrollview. hope you can get the idea :)
@jeremiasdsa what do u mean by creating a new xib looking like your scrollview, I am new to iOS can you please elaborate, I mean I have my scrollview present and there are some components in that, you mean to say we have to copy that content to new xib file, how to do that?
@kikukiran I just had to create Xib file with my views, without scroll. Also I didn't display this xib, I just use it fo fill up with some labels/images... (same info I've got on my scroll). So, I just generated a pdf from my xib that represents a copy of my view, but as I mentioned without scroll.
a simple solution is to add:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
scrollView.translatesAutoresizingMaskIntoConstraints = true
}
to your view controller after taking layout from your scrollView
Before generating the PDF file, we need to set the ScrollView's frame. That's the problem, you just need to set the ScrollView's frame equal to its own frame, and you can solve the problem. If you have other questions, you can add my wechat account: coobjc