<?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>Chewy Apps &#187; UIScrollView</title>
	<atom:link href="http://www.chewyapps.com/tag/uiscrollview/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chewyapps.com</link>
	<description>Hi, I&#039;m Henning, and I&#039;m an iPhone developer.</description>
	<lastBuildDate>Sat, 28 Jan 2012 19:00:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Images in a Scroll View</title>
		<link>http://www.chewyapps.com/2009/09/01/images-in-a-scroll-view/</link>
		<comments>http://www.chewyapps.com/2009/09/01/images-in-a-scroll-view/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 19:24:05 +0000</pubDate>
		<dc:creator>henning</dc:creator>
				<category><![CDATA[Development Tips]]></category>
		<category><![CDATA[UIImage]]></category>
		<category><![CDATA[UIScrollView]]></category>

		<guid isPermaLink="false">http://www.chewyapps.com/?p=229</guid>
		<description><![CDATA[I know that when I was a beginning iPhone developer doing things that seem so simple now weren&#8217;t so simple back then. Just because I didn&#8217;t know any better and was unaware of the tools and API&#8217;s available to me. One thing that I&#8217;ve been doing a lot recently is putting several images in a [...]]]></description>
			<content:encoded><![CDATA[<p>I know that when I was a beginning iPhone developer doing things that seem so simple now weren&#8217;t so simple back then. Just because I didn&#8217;t know any better and was unaware of the tools and API&#8217;s available to me.</p>
<p>One thing that I&#8217;ve been doing a lot recently is putting several images in a UIScrollView, so I thought I&#8217;d post the barebones version of the code here in case anyone finds it useful. Hopefully I&#8217;ll be able to add more snippets in the future.</p>
<div class="codesnip-container" >
<div class="c_mac codesnip" style="font-family:monospace;"><span class="co2">#define IMAGE_WIDTH &nbsp; 320</span><br />
<span class="co2">#define IMAGE_HEIGHT &nbsp;416</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; NSArray <span class="sy0">*</span>photos <span class="sy0">=</span> nil;&nbsp; &nbsp; &nbsp; <span class="co1">// TODO &#8211; fill with your photos</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">// note that the view contains a UIScrollView in aScrollView</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> i<span class="sy0">=</span><span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span> NSString <span class="sy0">*</span>image in photos <span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UIImage <span class="sy0">*</span>image <span class="sy0">=</span> <span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="br0">&#91;</span>photos objectAtIndex<span class="sy0">:</span>i<span class="br0">&#93;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UIImageView <span class="sy0">*</span>imageView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIImageView alloc<span class="br0">&#93;</span> initWithImage<span class="sy0">:</span>image<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; imageView.<span class="me1">contentMode</span> <span class="sy0">=</span> UIViewContentModeScaleAspectFit;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; imageView.<span class="me1">clipsToBounds</span> <span class="sy0">=</span> YES;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; imageView.<span class="me1">frame</span> <span class="sy0">=</span> CGRectMake<span class="br0">&#40;</span> IMAGE_WIDTH <span class="sy0">*</span> i<span class="sy0">++</span>, 0, IMAGE_WIDTH, IMAGE_HEIGHT<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>aScrollView addSubview<span class="sy0">:</span>imageView<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>imageView release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; aScrollView.<span class="me1">contentSize</span> <span class="sy0">=</span> CGSizeMake<span class="br0">&#40;</span>IMAGE_WIDTH<span class="sy0">*</span>i, IMAGE_HEIGHT<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; aScrollView.<span class="me1">delegate</span> <span class="sy0">=</span> self;<br />
<span class="br0">&#125;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.chewyapps.com/2009/09/01/images-in-a-scroll-view/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

