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
Related
I want to display formatted text in my iOS app and I have a lot of it (about as much text as a medium sized wikipedia entry) is a WebView with html the best way to display formatted text or is there a better way? I read on stackOverflow that WebViews suck a lot of memory, is that true? How does wikipedia display all of its text in its iOS app?
The main reason you should use UITextView or UILabel to display formatted text is that there is no ultimate way to get content bounds at the first time it is drawn in UIWebView.
You can use UIKit object whichever you can render NSAttributedString such as UITextView or UILabel.
If your content is html you can convert it to NSAttributedString.
I ended up using a WKWebView with a contrained height and width. That way I could load the HTML without any additional set up and I didn't run into any problems with the web views bounds.
I am trying to show some content on webview. No problem in showing the content. But, I have a text field at the end of the content. I want to fix it on my webview even I am in starting of the webview scroll.
It was done automatically if I enable page to fit for my webview. But, scale page to fit does not satisfy my requirement.
Any suggestions appreciated.
Thanks!
UIWebView has a property called scalesPageToFit, which can be set to YES or NO.
I was wondering if anyone had an explanation as to what it actually does with regards to how it works. What criteria is it looking at when it scales the page? Is it looking for the widest table or div and then zooming out to fit that?
Thanks
So far to my knowledge when you set scalesPageToFit to YES it will show the content within the Webview space.
Then you can zoom out to see the content according to the users capability of reading.
I have done this a few times for pdf file, so it will show the pdf content within the content width. Actually it will scale it proportionally.
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.
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