setting view port before loading HTML page in iOS - iphone

I am an iOS developer and i do not have any knowledge about web development.I am trying to load an HTML page on UIWebView since the content size of web page is larger then the iOS device screen size,the webview shows scroll bars which has to be avoided in my case.I want to fit the page to the webview width.
I did read some posts here and understood that i should change the viewport of HTML to get things work as i desired.When i manually change the width and height properties of meta tag in HTML its fitting to my webview.What is the best method to change the view port before loading page.
(I have seen approaches to set scale using stringByEvaluatingJavaScriptFromString: in webViewDidFinishLoading: and i can not prefer doing this because the webview takes time to load the content till then it shows the scalled page then it refreshes.)
Is there any better method to change meta propertied then reading HTML file in to NSString and do poor string level manipulations?The HTML pages are always available locally on the device.
Please help,i need to get it fixed as soon as possible.

Related

Get an image from a canvas HTML element in flutter?

In my flutter application, there is an image I would like to show that comes from another website. On that website, the image is actually a <canvas> element in HTML. I have seen resources about turning the Flutter Canvas into an image, or turning one's own <canvas> element into an image in JavaScript, but never anything about getting it from an external page.
The site I am trying to use is the NOAA Radar view. I could use a WebView to show the entire site but that seems needlessly heavy when I just need a still image.
What would be the best way about getting a still image from the site's <canvas> tag. I tried performing a http GET on the URL but there is no <canvas> tag present there when I do it in curl (via the html package). I believe this is because the canvas is rendered with JavaScript after the page loads.

Use rems in Facebook Page Plugin

I want to set up Page Plugin on my website to display nicely on screens with a variety of resolutions and pixel densities. In order to truly achieve that, I'd have to have to possibility to use rems in data-width attribute. Unfortunately, when I enter a rem value, the data-width attribute is ignored.
Is there a way to make the plugin behave nicely with rems?
To make the Facebook Page Plugin responsive on initial page load, instead of using rems, you'll want to remove the data-width attribute and instead add
data-adapt-container-width="true"
This will make the Facebook Page Plugin responsive, but only on the initial page render, with a minimum width of 180px.
I'm still trying to figure out how to make it truly dynamically responsive, in spite of Facebook's caveat (I'll post an update if I ever find the answer).
No Dynamic Resizing
The Page plugin works with responsive, fluid and static layouts. You
can use media queries or other methods to set the width of the parent
element, yet:
The plugin will determine its width on page load.
It will not react changes to the box model after page load.
If you want to adjust the
plugin's width on window resize, you manually need to rerender the
plugin.
Source: https://developers.facebook.com/docs/plugins/page-plugin
You could make it dynamically responsive by reinitializing the widget on browser resize, but by doing that you run the risk of eating up memory very quickly.
There is some other stuff you can try here as well
Responsive width Facebook Page Plugin

How to Scroll the web content loaded on UIWebView to a specific division/content start point?

I am new to iPhone apps Development.
I am developing an application in which i need to scroll the webpage loaded on UIWebView to a certain div having some Id. Since I am loading the static webpage by converting the web content into a string. String contains some anchor tags appear on the HTML page. so clicking on the anchor tag webView should scroll automatically to particular div containing the same title as the anchor tag's title is.
I am using stringByEvaluatingJavaScriptFromString.
I have used a lot of javascript available on the net as well as on the stack overflow but none was feasible in my case.
Is there any solution for my problem.

Display wordpress content on iPhone?

I know there is this WP Touch that can automatically resize the webpage to fit iphone size. But what I want to do is to get the contents of the site, not the whole site, and display it on iphone.
I manage to get the content from wp database, the wp_posts table, post_content column, and get the content. But the problem is that, the content from wp database, include the width and height, and some of the width exceed iphone resolution. Here is the sample code from wp content:
... bla bla
<table width="980px" ...>
...
Even in my UIWebView i set the size to 300px width, the content will be chopped off. Is there any work around way to handle this problem?
EDIT:
I can only access the database, cant access the wordpress (php files)
Consider using CSS Media queries. You can then set certain device sizes to display or not display some content. CSS Tricks: Media Queries
This is considered to be a much better solution because it will allow you to just maintain a single site, as opposed to multiple code bases.
I think that you can overwrite your table width property via CSS rule:
table {
width:300px !important;
}

iPhone UIWebView epubs split page by page

It's really interesting how book reading applications like Stanza or Eucalyptus split epubs which is html by page so lines are clear and next page starts at the correct line.
Does anyone has any idea how this could be accomplished?
The easiest way is to render a chapter inside an epub in a UIWebView and the use javascript to compute page boundaries. The interface between Cocoa and JS is kind of tricky but stringByEvaluatingJavaScriptFromString: can be used to run JS inside a UIWebView.
Once you have the page boundaries you can scroll the chapter using window.scrollTo(x,y); and adjust the size of your UIWebView according to your page boundaries to prevent any incomplete lines showing from the bottom.