PDF in UIWebView

↘锁芯ラ 提交于 2019-12-12 08:13:07

问题


I am creating a magazine app. I am displaying each page of my magazine in a UIWebView. The webview doesn't fill the screen with the PDF though. There is a border around it. How can I display it fullscreen?


回答1:


I have not tried this with a UIWebView, but you may be able to do something like this to programatically position the border so that it's offscreen:

CGRect frame = webView.frame;
// you may need to modify the 5 and 10 below to match the size of the PDF border
frame.origin.x = frame.origin.x - 5;
frame.origin.y = frame.origin.y - 5;
frame.size.width = frame.size.width + 10;
frame.size.height = frame.size.height + 10;
webView.frame = frame;

If you are using the UIWebView to display PDFs and HTML, you would of course only modify the frame when displaying a PDF, and then set the frame back to the original values when displaying other content.

I have done this type of thing with a UIScrollView for a different reason: to provide padding around the items displayed in the UIScrollView so that there would be a gap in scrolling (as demonstrated in Apple's PhotoScroller example from WWDC 2010). I'm guessing that this could also work to move the borders around the PDF off of the screen.




回答2:


Checking the Scale Page to Fit box in IB removed the border for me.



来源:https://stackoverflow.com/questions/3732052/pdf-in-uiwebview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!