I have a UIWebView that displays a PDF. By default it opens the PDF and scales it to fit the entire width in the view, but not the height. I want it to fill the view so that the height stretches down to the bottom.
I have tried using contentModeScaleToFill, zoomToRect, and any other thing that sounded like it might have any relevance.
Can anybody help with this?
You might want to try #Jeff's suggestion and use CGAffineTransformScale to rescale your pdf after it is loaded to fill the screen. Look at his answer here: https://stackoverflow.com/a/3600665/188675
And to answer your question, 1) contentModeScaleToFill is a UIView Constant so it won't help with anything in your case, because you're using a UIWebView. 2) Using CFAffineTransformScale is much more simple and straightforward than using zoomToRect because you don't have to mess with the scrollView.
Related
I have been trying to find a way to use a background image so that it is larger than the device screen size, IE: the user can scroll from top to bottom and side to side to view the entire image.
This is something I'm looking at in gaming. I just haven't found any way to do this, I know its because I'm looking in the wrong place or asking the question in an incorrect manner, so any help would be appreciated.
For this problem you can use scrollView and insert in it a content view , and give it say 3 times widths/heights of screen , see demo here ScrollAnyway
I'm trying to implement a UICollectionView that contains UIWebviews in each cell. I've almost got it working but I am having this problem of not being able to resize the webviews to the cell's content size. Each webview size so far is 1024x704 (width x height) and is a html file. I have enabled scalesPageToFit to YES but all it's doing right now is resizing it to only fit in the upper left corner.
I've checked the frame size of the webview and the collectionviewcell size and i get 1024x704 programmatically even though what is actually appearing seems to be a lot smaller than that.
Any suggestions/help on why this is happening and what I can do to scale it correctly? If I need to supply more info let me know. Thanks
EDIT:
As shown below this is how the UICollectionView looks like on an iPad. The rectangle in the left is the UIWebView and I'm trying to scale it to fit the whole screen.
EDIT2: Just realized I screwed up on how I wrote my html file. Sorry about that guys! Problem solved itself.
Try this:
self.webView=[[UIWebView alloc]initWithFrame:self.bounds];
self.webView.contentMode=UIViewContentModeScaleAspectFit;
self.webView.scalesPageToFit=YES;
self.webView.autoresizingMask=(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
I am having a problem with UIWebView. My application displays pdfs from local memory and displays them in a webView in fullscreen mode. By default, when the page loads, the content is apparently set to fit horizontally, which cuts off some of the bottom of the pdf. I would like it to initially show up vertically fit and horizontally centered. I have looked for an answer to this question for quit some time and can't seem to find anything.
Any ideas?
(Please do not suggest scalesPageToFit. Although it fixes many beginning problems, this is not one of them.)
uiWebView.scrollView property has the ability to set zoom and also manage display of content
UIScollView class ref
I want to show a small preview of the current area being displayed of UIScrollView like Sublime text editor does.
Imagine that my UIScrollView size is 640x480, but the content is 640x960.
When I scroll I want to be able to show a small preview of the whole UIScrollView content in the top right corner, making possible for the user to understand which part of the UIScrollView he is actually looking at.
How do I achieve such thing?
CAReplicator?
CAScrollLayer?
I'm kind of lost here so any tips would be awesome.
Thanks,
With my best regards,
Nuno
A noob here so it might take a while to understand what's the wrong, just follow along ..
the key purpose of my app is to download an xml file from rss feed then parse it and pass it as html file to a webview with this method: [webView loadHTMLString:aString baseURL:nil]
after the content took place in the webview it doesn't fit nice and neat instead there's some photos in the content that has a width larget than what it can be displayed at once without scrolling horizontally,as well as the attachments at the end of the webview you have to scroll a bit right or left to read the full name of it, it'd be nice if the content stretched so it can be seen without scrolling horizontally.
Notice that I adjusted webview property scalesPageToFit to be YES, but that scaled the content to very small size to the point that you can't read what it contains!
any solution around this?
You need to use a meta/viewport tag and se the content width. See documentation, here:
https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html