<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NSCoriolisBlog &#187; UIWebView</title>
	<atom:link href="http://blog.coriolis.ch/tag/uiwebview/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.coriolis.ch</link>
	<description>Just another Coriolis weblog</description>
	<lastBuildDate>Sat, 13 Mar 2010 09:43:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Extend UIWebView to handle all special links</title>
		<link>http://blog.coriolis.ch/2009/10/29/extend-uiwebview-to-handle-all-special-links/</link>
		<comments>http://blog.coriolis.ch/2009/10/29/extend-uiwebview-to-handle-all-special-links/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 21:57:09 +0000</pubDate>
		<dc:creator>Stephan</dc:creator>
				<category><![CDATA[cocoa]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[browsing]]></category>
		<category><![CDATA[UIWebView]]></category>

		<guid isPermaLink="false">http://blog.coriolis.ch/?p=235</guid>
		<description><![CDATA[Have you ever wanted to add an UIWebView to your application, so you can browse the internets without leaving your application? While it is a trivial task to add an UIWebView to a project, there are some links that an UIWebView will not handle. These are: mailto YouTube maps.google.com iTunes AppStore I&#8217;ve written a generic [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to add an UIWebView to your application, so you can browse the internets without leaving your application? While it is a trivial task to add an UIWebView to a project, there are some links that an UIWebView will not handle.</p>
<p>These are:</p>
<ul>
<li>mailto</li>
<li>YouTube</li>
<li>maps.google.com</li>
<li>iTunes</li>
<li>AppStore</li>
</ul>
<p>I&#8217;ve written a generic BrowserViewController, code available on GitHub here: <a  href="http://github.com/sburlot/browserviewcontroller">http://github.com/sburlot/browserviewcontroller</a> which handles all these cases:</p>
<p><strong>mailto</strong> links are handled with a MFMail: I tried to handle all variations on the link: &#8220;to&#8221;, &#8220;cc&#8221;, &#8220;subject&#8221; and &#8220;body&#8221;.</p>
<p><strong>YouTube</strong>, <strong>Map</strong>, <strong>iTunes</strong> and <strong>AppStore</strong> links are opened in their respective apps.</p>
<p>You can customise the view and decide if you want a navigation tab bar or not.</p>
<p>The navigation tab bar will add standard web buttons: Back, Forward, Stop, Reload and also a button to send the url of the current page via email, or open it in Safari.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.coriolis.ch/2009/10/29/extend-uiwebview-to-handle-all-special-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo fit text inside a UIWebView</title>
		<link>http://blog.coriolis.ch/2009/01/05/howto-fit-text-inside-a-uiwebview/</link>
		<comments>http://blog.coriolis.ch/2009/01/05/howto-fit-text-inside-a-uiwebview/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 22:25:14 +0000</pubDate>
		<dc:creator>Stephan</dc:creator>
				<category><![CDATA[cocoa]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[fit text]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[UIWebView]]></category>

		<guid isPermaLink="false">http://blog.coriolis.ch/?p=45</guid>
		<description><![CDATA[If, like me, you want to make sure your text will fit inside your UIWebView (without scrolling), you can implement the following javascript: &#60;script language=&#x27;javascript&#x27; type=&#34;text/javascript&#34;&#62; function adjustHeight(maxHeight) { elem = document.getElementById(&#34;sign&#34;); height = elem.offsetHeight; current_size = elem.style.fontSize.replace(&#x27;px&#x27;,&#x27;&#x27;)/1; while ((current_size-- &#62; 10) &#38;&#38; (height &#62; maxHeight)){ elem.style.fontSize = current_size + &#x27;px&#x27;; height = elem.offsetHeight; } [...]]]></description>
			<content:encoded><![CDATA[<p>If, like me, you want to make sure your text will fit inside your UIWebView (without scrolling), you can implement the following javascript:</p>
<pre><code>    &lt;script language=&#x27;javascript&#x27; type=&quot;text/javascript&quot;&gt;
    function adjustHeight(maxHeight) {
      elem = document.getElementById(&quot;sign&quot;);
      height = elem.offsetHeight;
      current_size = elem.style.fontSize.replace(&#x27;px&#x27;,&#x27;&#x27;)/1;
      while ((current_size-- &gt; 10) &amp;&amp; (height &gt; maxHeight)){
        elem.style.fontSize = current_size + &#x27;px&#x27;;
        height = elem.offsetHeight;
      }
    }
    &lt;/script&gt;
</code></pre>
<p>This script will reduce the size of the div until it fits the required height, but with a minimum font-size of 10px hardcoded.</p>
<p>Now in the html, call the adjustHeight function, passing it the id of the div to adjust:</p>
<pre><code>&lt;body onload=&quot;adjustHeight(48)&quot;&gt;
  &lt;div id=&quot;sign&quot; style=&quot;font-size:68px&quot;&gt;This is the text that fits&lt;/div&gt;
&lt;/body&gt;
</code></pre>
<p>The trick here is that to read the fontSize of a div, the font-size property should be inline. If the font-size is declared in the CSS, you&#8217;ll have to use another much more complex method, described in <a  href="http://developer.apple.com/internet/webcontent/styles.html">http://developer.apple.com/internet/webcontent/styles.html</a>.</p>
<p>PS: Instead of reading the font-size from the div, I could have hardcoded its value in the script, and avoided much trouble.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.coriolis.ch/2009/01/05/howto-fit-text-inside-a-uiwebview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk (enhanced)

Served from: www.coriolis.ch @ 2010-09-07 14:39:00 -->