<?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>Chomper Stomping &#187; iPhone App Development</title>
	<atom:link href="http://blog.chomperstomp.com/category/iphone-app-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.chomperstomp.com</link>
	<description>jQuery/JavaScript/CSS 3/HTML 5, Java/PHP/Python/ActionScript, Git, Chrome/Firefox Extensions, Wordpress/Game/iPhone App Development and other random techie tidbits I&#039;ve collected</description>
	<lastBuildDate>Wed, 04 Jan 2012 16:25:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>“Command  failed with exit code -1” error when compiling iPhone App for Device &#8211; 3.0 &#124; Release build</title>
		<link>http://blog.chomperstomp.com/%e2%80%9ccommand-failed-with-exit-code-1%e2%80%9d-error-when-compiling-iphone-app-for-device-3-0-release-build/</link>
		<comments>http://blog.chomperstomp.com/%e2%80%9ccommand-failed-with-exit-code-1%e2%80%9d-error-when-compiling-iphone-app-for-device-3-0-release-build/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 11:22:35 +0000</pubDate>
		<dc:creator>Christopher McCulloh</dc:creator>
				<category><![CDATA[iPhone App Development]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://blog.chomperstomp.com/?p=298</guid>
		<description><![CDATA[I recently installed the iPhone OS 3.0 upgrade on my iMac for developing iPhone Apps in XCode. The App I&#8217;ve been developing started throwing errors when I would try and compile for 3.0 (previously worked in 2.2.1). I fixed all of the errors I could, but I am consistently getting the following error: Command failed [...]]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=chompstomp-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=1430224592" style="width:120px;height:240px;float: left;margin-right: 10px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
<p>I recently installed the iPhone OS 3.0 upgrade on my iMac for developing iPhone Apps in XCode. The App I&#8217;ve been developing started throwing errors when I would try and compile for 3.0 (previously worked in 2.2.1). I fixed all of the errors I could, but I am consistently getting the following error:</p>
<p>Command <com.apple.tools.product-pkg-utility> failed with exit code -1</p>
<p>Any time I try and compile for the device (even 2.2.1 now&#8230;)</p>
<p>It works fine in the simulator (building for both release and debug) but will not work for the device (for release or debug).</p>
<p>The reason for this is because I accidentally installed the &#8220;Snow Leopard&#8221; version of the 3.0 SDK instead of the &#8220;Leopard&#8221; version (I&#8217;m just a poor ignorant PC guy who has no idea which animal his OS is named after and just wishes they would call it &#8220;X.5&#8243; or &#8220;X.6&#8243; to simplify things).</p>
<hr />
<p>If you found this post helpful, it was supported in part by the amazon links around the site. If you&#8217;re going to buy a book anyways, why not help support this blog&#8217;s author by clicking one of the links on this site to do it? If you are looking for a book on iPhone development, this one is amazing: <a href="http://www.amazon.com/gp/product/1430224592?ie=UTF8&#038;tag=chompstomp-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1430224592">Beginning iPhone 3 Development: Exploring the iPhone SDK</a><img src="http://www.assoc-amazon.com/e/ir?t=chompstomp-20&#038;l=as2&#038;o=1&#038;a=1430224592" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chomperstomp.com/%e2%80%9ccommand-failed-with-exit-code-1%e2%80%9d-error-when-compiling-iphone-app-for-device-3-0-release-build/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone 0S 3.0.1 not supported for development with Xcode SDK 3.0</title>
		<link>http://blog.chomperstomp.com/iphone-0s-3-0-1-not-supported-for-development-with-xcode-sdk-3-0/</link>
		<comments>http://blog.chomperstomp.com/iphone-0s-3-0-1-not-supported-for-development-with-xcode-sdk-3-0/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 16:38:58 +0000</pubDate>
		<dc:creator>Christopher McCulloh</dc:creator>
				<category><![CDATA[iPhone App Development]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[iPhone SDK 3.0]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SDK]]></category>

		<guid isPermaLink="false">http://blog.chomperstomp.com/?p=288</guid>
		<description><![CDATA[I recently updated my iPhone from iPhone OS Version 3.0 (7A341) to iPhone OS Version 3.0.1 (7A400). When I plugged it into my Mac, I was informed that: The version of iPhone OS on &#8220;Christopher&#8217;s iPhone&#8221; does not match any of the versions of iPhone OS supported for development with this copy of Xcode. Please [...]]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=chompstomp-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=1430224592" style="width:120px;height:240px;float: left;margin-right: 10px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
<p>I recently updated my iPhone from iPhone OS Version 3.0 (7A341) to iPhone OS Version 3.0.1 (7A400). When I plugged it into my Mac, I was informed that:</p>
<blockquote><p>The version of iPhone OS on &#8220;Christopher&#8217;s iPhone&#8221; does not match any of the versions of iPhone OS supported for development with this copy of Xcode. Please restore the device to a version of the OS listed below. If necessary, the latest version of Xcode is available here.</p></blockquote>
<p>Gee&#8230; Thanks&#8230; I did a little <a href="http://bc.tech.coop/blog/090731.html">Googling and found</a> that after a recent security update to the iPhone OS Apple, you could no longer build/install development apps on the iPhone. Apparently Apple posted an &#8220;advisory&#8221; (in PDF format for some reason) outlining a fix for this.</p>
<p>Here is the fix in plain text instead of PDF (why they put this in a PDF is beyond me&#8230;):</p>
<blockquote><p>
iPhone OS 3.0.1 Advisory<br />
iPhone OS 3.0 SDK and iPhone OS 3.0.1 software release for<br />
Mac OS X v10.5.7<br />
To continue development with iPhone SDK 3.0 on your iPhone, iPhone 3G and<br />
iPhone 3GS running iPhone OS 3.0.1 will need to perform the following:<br />
1. Log into your Mac with an Admin account and launch the Terminal application<br />
(/Applications/Utilities)<br />
2. Copy and paste the following line into Terminal:<br />
ln -s /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0\ \(7A341\) /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0.1<br />
Note: If you installed iPhone SDK 3.0 somewhere other than the default /Developer<br />
location, replace the &#8220;/Developer&#8221; directory as appropriate.<br />
© 2009 Apple Inc. All rights reserved. Xcode, Apple, the Apple logo, Mac, Mac OS, and Macintosh are<br />
trademarks of Apple Inc., registered in the U.S. and other countries.</p></blockquote>
<p>For some reason, the wonderful person who created the PDF put a hard break after the &#8220;/&#8221; right before the word &#8220;Developer&#8221;. So if you actually do copy and paste the line into the terminal as they instruct, it doesn&#8217;t work. However, if you copy and paste the plain text version on this page, it SHOULD work (no guarantees). If you want to copy and paste from the PDF, you will have to type everything following that &#8220;/&#8221; by hand, THEN it will work&#8230; Thanks Apple!</p>
<p><a href="http://adcdownload.apple.com/iphone/iphone_sdk_3.0__final/iphone_os_3.0.1_advisory.pdf">Here is a link to the advisory</a>.</p>
<p><strong>***UPDATE:</strong></p>
<p>Several people have had to use:<br />
<code><br />
ln -s /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0 /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0.1</code></p>
<hr />
<p>If you found this post helpful, it was supported in part by the amazon links around the site. If you&#8217;re going to buy a book anyways, why not help support this blog&#8217;s author by clicking one of the links on this site to do it? If you are looking for a book on iPhone development, this one is amazing: <a href="http://www.amazon.com/gp/product/1430224592?ie=UTF8&#038;tag=chompstomp-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1430224592">Beginning iPhone 3 Development: Exploring the iPhone SDK</a><img src="http://www.assoc-amazon.com/e/ir?t=chompstomp-20&#038;l=as2&#038;o=1&#038;a=1430224592" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chomperstomp.com/iphone-0s-3-0-1-not-supported-for-development-with-xcode-sdk-3-0/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Creating Dynamically Re-sizable Buttons for iPhone Apps</title>
		<link>http://blog.chomperstomp.com/creating-dynamically-re-sizable-buttons-for-iphone-apps/</link>
		<comments>http://blog.chomperstomp.com/creating-dynamically-re-sizable-buttons-for-iphone-apps/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 17:53:19 +0000</pubDate>
		<dc:creator>Christopher McCulloh</dc:creator>
				<category><![CDATA[iPhone App Development]]></category>
		<category><![CDATA[programming concepts]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[custom iPhone button]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[re-sizeable]]></category>
		<category><![CDATA[stretch-able]]></category>

		<guid isPermaLink="false">http://blog.chomperstomp.com/?p=211</guid>
		<description><![CDATA[Creating buttons that resize/stretch themselves automatically for your iPhone Applications is pretty easy.

Buttons are created as .png files with three parts: Left end-cap, middle (the stretch-able part), Right end-cap. Basically, you create a little tiny .png file with the left and right end caps (or top and bottom) and a little bity middle part that the iPhone will automatically re-size to fit any width or height you make the button.

I'll walk you through the process step by step and show you how to assign the image to your button.]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://rcm.amazon.com/e/cm?t=chompstomp-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=1430216263&#038;md=10FE9736YVPPT7A0FBG2&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=FFFFFF&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px; margin: 15px; float: left;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
<p>Creating buttons that resize/stretch themselves automatically for your iPhone Applications is pretty easy.</p>
<p>Buttons are created as .png files with three parts: Left end-cap, middle (the stretch-able part), Right end-cap. Basically, you create a little tiny .png file with the left and right end caps (or top and bottom) and a little bity middle part that the iPhone will automatically re-size to fit any width or height you make the button.</p>
<p>I&#8217;ll walk you through the process step by step and show you how to assign the image to your button.</p>
<p>If you are wondering how to get your Round Rect Buttons to look like the ones in the official iPhone apps (like the ones apple makes), this tutorial will show you how. Instead of creating your own button image, just use the ones from <a href="http://developer.apple.com/iphone/library/samplecode/UICatalog/index.html">Apple</a>, or download <a href="http://blog.chomperstomp.com/buttonTutorial.zip">the zip file for this tutorial</a> (the ones from Apple are in there too)</p>
<h2>Creating the Stretchable iPhone App Button Image</h2>
<p>To start with, you will need to actually create the button image. I used Fireworks to do this, but you could use Photoshop, Illustrator, Inkscape or Gimp if you are so inclined. I recommend Fireworks.</p>
<p>I wanted my button to mimic normal iPhone buttons, but also illustrate the concept of a &#8220;stretchy&#8221; button. So I made a square button with rotated square corners.</p>
<ol>
<li>Create a new image 30 x 50 (or there-abouts)</li>
<p><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/step1.png" alt="step1" title="step1" width="473" height="405" class="alignnone size-full wp-image-229" /></p>
<li>Make sure to set the canvas color as &#8220;transparent&#8221;</li>
<li>Mock-up your button shape</li>
<p><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/step2.png" alt="step2" title="step2" width="120" height="50" class="alignnone size-full wp-image-230" /></p>
<li>Use the pen tool to trace it into a single shape<br /><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/step3.png" alt="step3" title="step3" width="59" height="50" class="alignnone size-full wp-image-231" />
<p><em>I take the individual components from the last step, group them together, and lock them, and then trace around them with the pen tool. There&#8217;s probably a better way, but this is the way I know. Use the guides to help you tweak it until you are satisfied</em></p>
</li>
<li>Trace a smaller version of the button inside of the outline using the pen tool</li>
<li>Fill in the inner button, and remove the line on it</li>
<li>Fill in the outer button</li>
<p><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/step4.png" alt="step4" title="step4" width="89" height="50" class="alignnone size-full wp-image-232" /></p>
<p>If the shape looks how you want it at this point, move on, otherwise, rinse and repeat&#8230;</p>
<li>Color the button the way you want it<br /><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/step5.png" alt="step5" title="step5" width="89" height="50" class="alignnone size-full wp-image-233" />
<p><em>The way I do this is to fill the outside shape with a dark grey (at the top) to light grey (at the bottom) linear gradiant with a 1px solid dark grey border (a little darker than the darkest part of the gradient). Then fill the inside shape with a custom linear gradient. This is the part that requires finesse. If you want it to look like an Apple button with the slick horizon line, start light, get progressively darker, and then in one pixel make a stark jump to the darkest shade of the color you are using, then get progressively light again.</em></p>
<p><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/step5gradient.png" alt="step5gradient" title="step5gradient" width="209" height="161" class="alignnone size-full wp-image-235" /></li>
<li>Add a drop shadow to the inner shape <br /><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/step5dropshadow.png" alt="step5dropshadow" title="step5dropshadow" width="176" height="100" class="alignnone size-full wp-image-234" />
<p><em>Click the inner shape. Click the &#8220;+&#8221; next to &#8220;Filters&#8221; in the Properties inspector. Select &#8220;Shadow and Glow > Drop Shadow&#8221;. I&#8217;ve selected a distance of 2, Opacity of 100%, Softness of 1 and Angle of 267.</em></p>
</li>
<li>Decide on the stretching points of your button
<p><em>Pick a point in the middle of the image where if that one pixel got stretched (repeated over and over again) to widen the button, it would look good (I chose 15px for the button I&#8217;ve been creating for this tutorial). Pick a point in the middle of the image where if that one pixel got stretched to lengthen the button, it would look good (I chose 27px for the button I&#8217;ve been creating for this tutorial). Make note of these two points as you will need to know them later.</em></p>
</li>
<p>At this point you have completed the &#8220;up&#8221; state for the button.
<li>Save your file <em>(I saved as &#8220;customButtonImageDefault.png&#8221;)</em></li>
<li>&#8220;Save As&#8221; and rename your file for the pressed or &#8220;down&#8221; state for the button <em>(I saved as &#8220;customButtonImageDown.png&#8221;)</em></li>
<li>Choose a color for the downstate, and change each gradient point to a shade of that color.<br /><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/step6.png" alt="step6" title="step6" width="674" height="394" class="alignnone size-full wp-image-245" />
<p><em>It makes it easier if you click the color wheel in the color chooser and use the slider on the right. Also, once you have chosen your base color after clicking the color wheel and adjusting the slider, click &#8220;Add to Custom Colors&#8221; so you don&#8217;t have to re-find your base color again and again each time. You can just select it from the custom colors list at the bottom left of the color wheel menu and then use the slider to choose another shade of that color. Make sure not to move any of gradient points or they won&#8217;t match up with the points you took note of earlier. Up states and Down states can have different stretch points if you want since you define each state&#8217;s stretch points individually in the code, but it makes it easier if you just use the same points for up and down.</em></p>
</li>
<li>Once you have edited all of the points. Open the images in fireworks and switch back and forth between them to compare how it&#8217;s going to look when the button is pressed. When satisfied, save. Now you&#8217;re ready to get to coding!</li>
<p><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/custombuttonimagedefault.png" alt="custombuttonimagedefault" title="custombuttonimagedefault" width="29" height="50" class="alignnone size-full wp-image-246" /><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/custombuttonimagedown.png" alt="custombuttonimagedown" title="custombuttonimagedown" width="29" height="50" class="alignnone size-full wp-image-247" />
</ol>
<h2>Creating a Custom Re-sizable Button in an iPhone App</h2>
<p>Ok, now that you&#8217;ve gotten your button created, it&#8217;s time to implement it.</p>
<p>I expect you to already know how to create I phone apps, but if not, here are un-annotated pictures of me building the scaffolding to hold our custom buttons. Following the images are the explanation on how to use custom buttons.</p>
<h3>Creating the Scaffolding to place the custom button in</h3>
<p><em>Again, if you already have an app you are trying to use the custom button in, skip this step&#8230;</em></p>
<p><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorial1.png" alt="buttontutorial1" title="buttontutorial1" width="600" height="442" class="alignnone size-full wp-image-252" /><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorial2.png" alt="buttontutorial2" title="buttontutorial2" width="788" height="559" class="alignnone size-full wp-image-253" /><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorial3.png" alt="buttontutorial3" title="buttontutorial3" width="728" height="476" class="alignnone size-full wp-image-254" /><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorial4.png" alt="buttontutorial4" title="buttontutorial4" width="728" height="476" class="alignnone size-full wp-image-255" /></p>
<h3>Making the Custom Button in the iPhone App</h3>
<ol>
<li>Open the interface builder and click on the button you would like to customize<br />
<img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorial5.png" alt="buttontutorial5" title="buttontutorial5" width="320" height="502" class="alignnone size-full wp-image-256" /></li>
<li>Open the &#8220;Button Attributes&#8221; pane (Apple + 1)</li>
<li>For &#8220;type&#8221; select &#8220;Custom&#8221;<br /><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorial6.png" alt="buttontutorial6" title="buttontutorial6" width="609" height="266" class="alignnone size-full wp-image-257" />
<p><em>At this point, if you didn&#8217;t give the button a title, it will disappear (which is ok). If you need to find it and can&#8217;t, in the main window (titled yourFileName.xib) there will be several objects. Expand the one that says &#8220;View&#8221; (or wherever you put your button) and you should see your button. Clicking on it there will highlight it in the layout window.</em></p>
</li>
<li>Hold down &#8220;ctrl&#8221; and drag from the &#8220;File&#8217;s Owner&#8221; object to the button.
<p><em>This can all be done from within the .xib window by switching to &#8220;list&#8221; view mode</em></p>
</li>
<li>In the little context menu that pops up, select &#8220;customButton&#8221; (or whatever you called the button in your code)<br /><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorialconnectbuttontooutlet.png" alt="buttontutorialconnectbuttontooutlet" title="buttontutorialconnectbuttontooutlet" width="354" height="198" class="alignnone size-full wp-image-263" /></li>
<li>Switch to the &#8220;size&#8221; window (Apple + 3)</li>
<li>Set the size to at least 100 x 100<br /> <img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorialbuttonsize.png" alt="buttontutorialbuttonsize" title="buttontutorialbuttonsize" width="287" height="201" class="alignnone size-full wp-image-260" />
<p><em>This is just so we can see our image stretch. When you are doing this in a non-tutorial setting, you will probably not set this at all.</em></p>
</li>
<li>Switch to the &#8220;Attributes&#8221; window (Apple + 1)</li>
<li>In the &#8220;View&#8221; section (at the bottom), click on &#8220;Background&#8221;<br /> <img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorialclickbackground.png" alt="buttontutorialclickbackground" title="buttontutorialclickbackground" width="286" height="217" class="alignnone size-full wp-image-261" /></li>
<li>In the &#8220;color&#8221; window that pops up, set &#8220;Opacity&#8221; to &#8220;0&#8243; (zero)<br /> <img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorialopacity.png" alt="buttontutorialopacity" title="buttontutorialopacity" width="218" height="375" class="alignnone size-full wp-image-251" /></li>
<li>Switch back over to Xcode</li>
<li>Locate your button files and drag and drop them into the &#8220;Resources&#8221; folder of your project<br /> <img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorial7.png" alt="buttontutorial7" title="buttontutorial7" width="400" height="374" class="alignnone size-full wp-image-258" />
<p></em>You will probably want to make sure and click the &#8220;Copy items into destination group&#8217;s folder&#8221; button</em></p>
</li>
<li>Click &#8220;Add&#8221; in the pop-up that appears</li>
<li>Switch to your view controller file
<p><em>(the one that corresponds with the view you were just editing in the Interface Builder. The one that ends with &#8220;.m&#8221;)</em></p>
</li>
<li>Add the following code to the -(void)viewDidLoad{} method:<br />
<br /><img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorial8.png" alt="buttontutorial8" title="buttontutorial8" width="1055" height="567" class="alignnone size-full wp-image-259" /><br />
<code><br />
UIImage *buttonImageNormal = [UIImage imageNamed:@"customButtonImageDefault.png"];<br />
UIImage *stretchableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];<br />
[customButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];</p>
<p>UIImage *buttonImagePressed = [UIImage imageNamed:@"customButtonImageDown.png"];<br />
UIImage *stretchableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];<br />
[customButton setBackgroundImage:stretchableButtonImagePressed forState:UIControlStatePressed];<br />
</code></p>
<p><em>The first block of code defines the image for the normal (up) state of the button. The second block defines the image for the pressed (down) state of the button. The first line of each block loads the button image for that state into the app. The second line of each block you can set the stretch points of the button (you should have noted these earlier when you made the button). You can keep setting these to different things and viewing the result to refine until you like what you see. The third line assigns the now stretchable image to the actual button. If you have more than one button you want to assign the image to, just copy the third line and replace &#8220;customButton&#8221; at the beginning with the name of the next button you want to assign the image to:</em></p>
<p><code><br />
UIImage *buttonImagePressed = [UIImage imageNamed:@"customButtonImageDown.png"];<br />
UIImage *stretchableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];<br />
[customButton setBackgroundImage:stretchableButtonImagePressed forState:UIControlStatePressed];<br />
[anotherCustomButton setBackgroundImage:stretchableButtonImagePressed forState:UIControlStatePressed];<br />
[thirdCustomButton setBackgroundImage:stretchableButtonImagePressed forState:UIControlStatePressed];<br />
</code></p>
<p><em>In this way, you can assign the image to as many buttons as you want.</em></p>
</li>
<p>Your viewDidLoad method should now look something like this:</p>
<p><code><br />
-(void)viewDidLoad {<br />
    UIImage *buttonImageNormal = [UIImage imageNamed:@"customButtonImageDefault.png"];<br />
    UIImage *stretchableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];<br />
    [customButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];</p>
<p>    UIImage *buttonImagePressed = [UIImage imageNamed:@"customButtonImageDown.png"];<br />
    UIImage *stretchableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];<br />
    [customButton setBackgroundImage:stretchableButtonImagePressed forState:UIControlStatePressed];</p>
<p>    [super viewDidLoad];<br />
}<br />
</code></p>
<li>Now hit Apple + R to compile, run and view the output!<br /> <img src="http://blog.chomperstomp.com/wp-content/uploads/2009/06/buttontutorialcomplete.png" alt="buttontutorialcomplete" title="buttontutorialcomplete" width="386" height="742" class="alignnone size-full wp-image-262" /></li>
</ol>
<p>A good amount of the information for this article came from<br />
<a href="http://www.amazon.com/gp/product/1430216263?ie=UTF8&#038;tag=chompstomp-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1430216263">Beginning iPhone Development: Exploring the iPhone SDK</a><img src="http://www.assoc-amazon.com/e/ir?t=chompstomp-20&#038;l=as2&#038;o=1&#038;a=1430216263" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />. It&#8217;s an excellent book. By far the best iPhone development book out there right now. It&#8217;s really easy to read and understand. Each chapter is one or two example projects from start to finish, step by step, wonderfully explained. After buying this book I had my first iPhone App up and running within a week. The thing they don&#8217;t talk about (that I did) was actually creating the button image, and dealing with the opacity. Again, all of the files for this tutorial can be downloaded from <a href="http://blog.chomperstomp.com/buttonTutorial.zip">here</a>.  Feel free to leave any feedback/questions/whatever in the comments&#8230; Good luck!</p>
<p><script type="text/javascript" src="http://www.assoc-amazon.com/s/link-enhancer?tag=chompstomp-20&#038;o=1">
</script><br />
<noscript><br />
    <img src="http://www.assoc-amazon.com/s/noscript?tag=chompstomp-20" alt="" /><br />
</noscript></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chomperstomp.com/creating-dynamically-re-sizable-buttons-for-iphone-apps/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

