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
Related
I'm pretty new in creating iOS applications and currently I'm following Apple's starter tutorial.
They suggest simulating on iPhone 6 which has a pretty big screen and therefore all the content fit its screen, however I'm simulating on iPhone 4 which has a smaller screen. All the content don't fit and I can't see all of the placeholder image. I'd expect that I would automatically be able to scroll so I'm able to view all the content but no.
It seems that you have designed your contents on normal view. Instead you have to use UIScrollView which will allow you to scroll to see all your contents. contentSize property is important for this.
Refer Here: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScrollView_Class/
The UIScrollView class provides support for displaying content that is
larger than the size of the application’s window. It enables users to
scroll within that content by making swiping gestures, and to zoom in
and back from portions of the content by making pinching gestures.
I'd like to create a UIWebView which behaves exactly like Apple's Safari when it comes to scrolling.
I want to have a UINavigationBar that appears gradually as as you scroll downwards on top of the page and hides gradually as you scroll upwards.
The most important thing is that I want it to always bounce just like the way Safari's UIWebView bounces.
In order to understand what I'm saying create a new project, add a UIWebView and load dribbble.com. You will notice that when you scroll down the dribbble's navigation bar stays in the same position.
But, what I want it to behave is just like Safari, here's what I want it to scroll like:
http://postimg.org/image/6e5qg6omh/
The reason is because behind the UIWebView (where the gray are is in the picture) I want to display an image. That image will be shown when you scroll down.
I tried setting webView.scrollView.alwaysBouncesVertical = YES; but it didn't work.
Any ideas?
Just an idea, making the region of the bar hidden past the top, then set it to always slide back if a certain length (lengthOfBarVisible < lengthOfBar) {move -.5 on the x axis}
Im a rookie so I'm probably way off.
Good luck though!
I discovered that in fact the UIWebView works exactly the way I want it to but the new WKWebView which I'm using is behaving in an odd way. There's nothing I can do I just hope that Apple fixes it.
I met this weird problem when I had an UIScrollView with pagingEnable = YES and a very large contentSize (let's say over 20000000).
Basically I want to write a PDF viewer just like the iBooks (showing one page in the screen). So the bounds of the UIScrollView is just the size of the screen, but the contentSize will be "the page number of the PDF" * "page width". This worked for small PDF, but with large PDF, the paging function seems broken.
For example, I had a 94MB PDF with over 20000 pages, the width of contentSize will be over 20000000. For the first 3000 pages (approximately), the paging works fine: the scrollview always bounces the page to the center of screen. But after 3000 pages, you will find that the bouncing becomes slow, not that smooth. And start from some page, the bouncing totally broken: the page will not show in the center, but stuck at somewhere else, just like pagingEnable = NO. It doesn't bounce anymore.
At first I thought it was something wrong with my code, but I suprisingly find that the iBooks has the same problem! I can't even trigger the toolbar with a single tap after scrolling the last page. So I'm wondering is this an iOS bug?
More Info: When debugging, I found that after the finger touched up, -scrollViewDidScroll: gets called for many times, which is normal, because the UIScrollView starts bouncing when pagingEnable = YES. But the problem is that the -scrollViewDidEndDecelerating: never gets called. Seems like the bouncing animation is broken at some middle point. Weird.
the PDF is only 94MB
File size does not equal the size in memory. PDFs are compressed, but they have to be uncompressed for display.
What's also important is that you don't need a scroll view that's as wide as the entire book - you only need a scroll view that's three pages wide. This is because a) you're hopefully already recycling your page views, and b) because only one page is visible on the screen at any one time you can move the content around as and when you need to.
Is there any reason you are not using a UIPageViewController, which is designed pretty much for this purpose?
Bottom line: there's no reason for your scroll view to be that wide. It only need to be a few pages wide, and you can move the views around to give the illusion the scroll view is much bigger than it actually is. If you search StackOverflow you'll almost certainly find a number of answers that do basically this.
I am sure this is an easy question, but I am lost. I have MWPhotoBrowser and a bunch of photos loaded into the browser. Everything works beautifully, except if I click on an image in the browser and drag it around the screen it moves everywhere and repositions the image. Essentially I just want to stop if from dragging around all together.
Any recommendations ?
There were two issues causing this problem:
Autolayout was turned off. Since I wanted it to remain off I had to create a work around with #2.
The content appears to be sized to the View. In my case the view height was much larger than the available display area on the screen. To work around the issue I used another view sized to the viewable area and added the browser to that view rather than the super view.
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