<?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>iPhone Programming Tutorials &#187; Interface Builder</title>
	<atom:link href="/tag/interface-builder/feed/" rel="self" type="application/rss+xml" />
	<link>http://icodeblog.com</link>
	<description>iPhone Programming Tutorials</description>
	<lastBuildDate>Tue, 19 Nov 2013 19:34:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.1</generator>
	<item>
		<title>Adding a UIPopover to UISlider</title>
		<link>http://icodeblog.com/2010/10/29/adding-a-uipopover-to-uislider/</link>
		<comments>http://icodeblog.com/2010/10/29/adding-a-uipopover-to-uislider/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 17:29:24 +0000</pubDate>
		<dc:creator><![CDATA[Collin]]></dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[ELC Class]]></category>
		<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[UIPopover]]></category>
		<category><![CDATA[UIPopoverController]]></category>
		<category><![CDATA[UISlider]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=2566</guid>
		<description><![CDATA[If you have an iPad you have probably used iBooks, Apple's eBook application that gives users access to the iBooks store. In this application you can navigate through books in a number of ways. Today we are going to focus on the scroll bar at the bottom of a book that a user can utilize to skip to any given page within the book. This control involves a customized UISlider and a UIPopoverView that drags along with the slider as the value changes. Today we will be making a UISlider subclass that will duplicate this functionality.]]></description>
				<content:encoded><![CDATA[<h2>Overview</h2>
<p>If you have an iPad you have probably used iBooks, Apple&#8217;s eBook application that gives users access to the iBooks store. In this application you can navigate through books in a number of ways. Today we are going to focus on the scroll bar at the bottom of a book that a user can utilize to skip to any given page within the book. This control involves a customized UISlider and a UIPopoverView that drags along with the slider as the value changes. Today we will be making a UISlider subclass that will duplicate this functionality.</p>
<h2>How to Use</h2>
<p><iframe src="http://player.vimeo.com/video/16261562?portrait=0&amp;color=ff9933" width="600" height="375" frameborder="0"></iframe>
<p><a href="http://vimeo.com/16261562">ELCSlider Demo</a> from <a href="http://vimeo.com/user2008025">Collin Ruffenach</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>So that is it! Put a UISlider in your XIB and then change its class to ELCSider. You can change the range of the slider through interface builder and the slider will work the same way. If you would like to change the appearance of the pop over, the number of digits that are shown or anything else you will need to change a bit of code. Look below for how the magic of this subclass is done.</p>
<h2>GitHub</h2>
<p>You can find this project <a title="ELCSlider on GitHub" href="http://github.com/elc/ELCSlider" target="_blank">now on GitHub</a>. Please let me know any issues you may have. Happy coding!</p>
<h2>How its Made</h2>
<p>The ELCSlider package is a collection of 5 files. 2 classes and 1 XIB. The first class that we will look at is the ELCSlider class which is a UISlider subclass. First taking a look at the header, we declare a class property PopoverController and SliderValueViewController. You can see the code below.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;">&nbsp;</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;">&nbsp;</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;SliderValueViewController.h&quot;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> ELCSlider <span style="color: #002200;">:</span> UISlider <span style="color: #002200;">&#123;</span>
&nbsp;
	UIPopoverController <span style="color: #002200;">*</span>popoverController;
	SliderValueViewController <span style="color: #002200;">*</span>sliderValueController;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>

<p>With the simple header declared we can go into the main of the ELCSlider. The first method you see in the main is the initWithCoder: method. This gets us into an interesting part of the iOS SDK that I we should investigate quickly. Looking at where initWithCoder: is declared, we see that it is a part of the NSCoding Protocol. This method is passed an archived object and is essentially to take saved files and turn them back into Objective C objects. If you ever create a custom class, and you want to save an instance of that class to a file, you will need to have that class conform to the NSCoding Protocol. If we look down the inheritance chain of a UISlider we will see that UIView indeed conforms to this protocol. This is because all UIView&#8217;s are going to need to archive and unarchive themselves from a .XIB file. As a result of this, when you lay out an element in a XIB the initialization method that will be called will be initWithCoder. Within the method we ensure that our super class initialized properly, and then we proceed to assign the method valueChanged: to the control event UIControlEventValueChanged. This will make a call to the valueChanged method to let us handle moving the UIPopoverView around based on the current value of the slider. After that we create an instance of our SliderValueViewController, which we will go through in the next section, and create a UIPopoverController with the content view controller being our SliderValueViewController. You can see the code for our initialization method below.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithCoder<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSCoder</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>aDecoder <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super initWithCoder<span style="color: #002200;">:</span>aDecoder<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
		<span style="color: #002200;">&#91;</span>self addTarget<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>valueChanged<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> forControlEvents<span style="color: #002200;">:</span>UIControlEventValueChanged<span style="color: #002200;">&#93;</span>;
&nbsp;
		sliderValueController <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>SliderValueViewController alloc<span style="color: #002200;">&#93;</span> initWithNibName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;SliderValueViewController&quot;</span> bundle<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
		popoverController <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIPopoverController alloc<span style="color: #002200;">&#93;</span> initWithContentViewController<span style="color: #002200;">:</span>sliderValueController<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>popoverController setPopoverContentSize<span style="color: #002200;">:</span>sliderValueController.view.frame.size<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #a61390;">return</span> self;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>The only remaining method to make is the method to handle what happens when the slider value changes. This method is all about doing the math to calculate the CGRect where we want out UIPopoverView to show itself. This is a value that will be derived based on the x origin of the slider, the slider width, the slider&#8217;s max and min, the current value and the size of the slider circular button (22px). I wrote this class so that it supports any type of slider range, positive to positive, negative to positive and negative to negative. The math is kind complex to figure out exactly where to display the pop over, but you can take a look at the source if you are curious. The real trick was measuring the width of the UISlider circular button as the center of it doesn&#8217;t go all the way to the edge of the slider, you you need to add or subtract some small amount to the x coordinate you compute depending on the value the slider is reporting. You can see the method below.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>valueChanged <span style="color: #002200;">&#123;</span>
&nbsp;
	<span style="color: #002200;">&#91;</span>sliderValueController updateSliderValueTo<span style="color: #002200;">:</span>self.value<span style="color: #002200;">&#93;</span>;
&nbsp;
	CGFloat sliderMin <span style="color: #002200;">=</span>  self.minimumValue;
	CGFloat sliderMax <span style="color: #002200;">=</span> self.maximumValue;
	CGFloat sliderMaxMinDiff <span style="color: #002200;">=</span> sliderMax <span style="color: #002200;">-</span> sliderMin;
	CGFloat sliderValue <span style="color: #002200;">=</span> self.value;
&nbsp;
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>sliderMin &lt; <span style="color: #2400d9;">0.0</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
		sliderValue <span style="color: #002200;">=</span> self.value<span style="color: #002200;">-</span>sliderMin;
		sliderMax <span style="color: #002200;">=</span> sliderMax <span style="color: #002200;">-</span> sliderMin;
		sliderMin <span style="color: #002200;">=</span> <span style="color: #2400d9;">0.0</span>;
		sliderMaxMinDiff <span style="color: #002200;">=</span> sliderMax <span style="color: #002200;">-</span> sliderMin;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	CGFloat xCoord <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>sliderValue<span style="color: #002200;">-</span>sliderMin<span style="color: #002200;">&#41;</span><span style="color: #002200;">/</span>sliderMaxMinDiff<span style="color: #002200;">&#41;</span><span style="color: #002200;">*</span><span style="color: #002200;">&#91;</span>self frame<span style="color: #002200;">&#93;</span>.size.width<span style="color: #002200;">-</span>sliderValueController.view.frame.size.width<span style="color: #002200;">/</span><span style="color: #2400d9;">2.0</span>;
&nbsp;
	CGFloat halfMax <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>sliderMax<span style="color: #002200;">+</span>sliderMin<span style="color: #002200;">&#41;</span><span style="color: #002200;">/</span><span style="color: #2400d9;">2.0</span>;
&nbsp;
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>sliderValue &gt; halfMax<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
		sliderValue <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>sliderValue <span style="color: #002200;">-</span> halfMax<span style="color: #002200;">&#41;</span><span style="color: #002200;">+</span><span style="color: #002200;">&#40;</span>sliderMin<span style="color: #002200;">*</span><span style="color: #2400d9;">1.0</span><span style="color: #002200;">&#41;</span>;
		sliderValue <span style="color: #002200;">=</span> sliderValue<span style="color: #002200;">/</span>halfMax;
		sliderValue <span style="color: #002200;">=</span> sliderValue<span style="color: #002200;">*</span><span style="color: #2400d9;">11.0</span>;
&nbsp;
		xCoord <span style="color: #002200;">=</span> xCoord <span style="color: #002200;">-</span> sliderValue;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>sliderValue &lt;  halfMax<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
		sliderValue <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>halfMax <span style="color: #002200;">-</span> sliderValue<span style="color: #002200;">&#41;</span><span style="color: #002200;">+</span><span style="color: #002200;">&#40;</span>sliderMin<span style="color: #002200;">*</span><span style="color: #2400d9;">1.0</span><span style="color: #002200;">&#41;</span>;
		sliderValue <span style="color: #002200;">=</span> sliderValue<span style="color: #002200;">/</span>halfMax;
		sliderValue <span style="color: #002200;">=</span> sliderValue<span style="color: #002200;">*</span><span style="color: #2400d9;">11.0</span>;
&nbsp;
		xCoord <span style="color: #002200;">=</span> xCoord <span style="color: #002200;">+</span> sliderValue;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #002200;">&#91;</span>popoverController presentPopoverFromRect<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">&#40;</span>xCoord, <span style="color: #2400d9;">0</span>, sliderValueController.view.frame.size.width, sliderValueController.view.frame.size.height<span style="color: #002200;">&#41;</span> inView<span style="color: #002200;">:</span>self permittedArrowDirections<span style="color: #002200;">:</span>UIPopoverArrowDirectionDown animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<h2>Creating the Popover&#8217;s Content View Controller</h2>
<p>Now that we have all of the logic in place to move the view controller appropriately, we need to create the view controller that will be injected into the Popover. The view controller I have created is meant to be restyled, refactored or even replaced. The view controller has one required method, updateSliderValueTo:. This method is called every time the slider value changes. People may use this method to change other aspects of the content view controller, such as background color, or possibly other labels. Please feel free to customize as much as you like.</p>
<h2>GitHub</h2>
<p>You can find this project <a title="ELCSlider on GitHub" href="http://github.com/elc/ELCSlider" target="_blank">now on GitHub</a>. Please let me know any issues you may have. Happy coding!</p>
<p>Follow me on twitter <a href="http://www.twitter.com/cruffenach">@cruffenach</a></p>
]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2010/10/29/adding-a-uipopover-to-uislider/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>UITabBar iPhone Tutorial</title>
		<link>http://icodeblog.com/2008/09/28/uitabbar-iphone-tutorial/</link>
		<comments>http://icodeblog.com/2008/09/28/uitabbar-iphone-tutorial/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 20:06:43 +0000</pubDate>
		<dc:creator><![CDATA[brandontreb]]></dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[iPhone apps]]></category>
		<category><![CDATA[iphone programming]]></category>
		<category><![CDATA[UITabBar]]></category>
		<category><![CDATA[UITabBarItem]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=449</guid>
		<description><![CDATA[This tutorial will show you the basics of using the UITabBar and UITabBarItem controls when programming for the iPhone.
I will be showing you step by step in the video how to create a project from a UITabBar template and add additional UITabBarItems as well as additonal views to be displayed with these items.  Here is a brief explanation of each step:
1. Create a new project from a UITabBar template
This is pretty straight forward.  We will be using Apple&#8217;s  ...]]></description>
				<content:encoded><![CDATA[<p>This tutorial will show you the basics of using the <strong>UITabBar</strong> and <strong>UITabBarItem</strong> controls when programming for the iPhone.</p>
<p>I will be showing you step by step in the video how to create a project from a <strong>UITabBar</strong> template and add additional <strong>UITabBarItems</strong> as well as additonal views to be displayed with these items.  Here is a brief explanation of each step:</p>
<h3>1. Create a new project from a UITabBar template</h3>
<p>This is pretty straight forward.  We will be using Apple&#8217;s default UITabBar template to start our project.  This is a fully functioning app.  You can click Build and Go to see it run.</p>
<h3>2. Open Interface Builder (click on mainWindow.xib) and Add addtional UITabBar items</h3>
<p>To add additonal UITabBarItems, you simply drag them from the library on to the UITabBar.  For each new item, you must specify the name of the view that will be shown when the item is clicked.  This is done by clicking on the tab bar item and clicking Tools -&gt; attributes inspector.  There should be a box titled &#8220;Nib Name&#8221;.  Whatever you enter here will be the name of the view that will be loaded when this tab is clicked.</p>
<p>So for this tutorial, we entered ThirdView.  So, naturally when we created our view to be loaded here, we saved it as &#8220;ThirdView.xib&#8221;.  This is one Gotcha when working with these components.</p>
<h3>3. Changing the text of the UITabBarItems</h3>
<p>This is took me a while to figure out.  To change the text, image, or style of the UITabBarItem, double click on it.  You should now be able to access these settings in the Attributes Inspector.</p>
<h3>4. Set the Background Color For Views 1 and 2</h3>
<p>This was pretty easy.  For the first view, we simply clicked on it and clicked the box next to &#8220;Background&#8221; in the Attributes Inspector.  Next, we did the same to the secondView by opening up SecondView.xib in Interface Builder.</p>
<h3>5. Create ThirdView</h3>
<p>We need to create the third view to be loaded when the user clicks on the UITabBarItem that we inserted.  This was done inside of Interface Builder by clicking File -&gt; new and selecting View. The next thing we did was drag a label from the library and add it to the view.  Finally, we set the background color like we did in the other views.</p>
<p>Be sure when you save this view, you name it ThirdView.xib (this corrisponds the name that we put in the &#8220;Nib Name&#8221; box in step 2).  Also, be sure to save this view in your projects folder (sometimes Interface Builder does not navigate here by default).</p>
<h3>6. Connecting ThirdView to the ViewController</h3>
<p>In this step we connect the ThirdView to our FirstViewController.  Notice that all of the views get connected to this view controller.  This will handle all of the UI components put on to each view. *Note: this step can&#8217;t be done until ThirdView is saved and added to the project.</p>
<p>So to connect this view to FirstViewController, simply click on the File&#8217;s Owner object and select FirstViewController from the drop-down in the Identity Inspector.</p>
<p>The last thing we need to do is connect the view.  So control-click from File&#8217;s Owner and drag the line to the View object. The word &#8220;View&#8221; should pop up.  Click on it and the views are now connected.</p>
<p>That should be it! Click Build and Go and you are done.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/sh1.png"><img class="size-full wp-image-452 aligncenter" title="Screenshot" src="/wp-content/uploads/2008/09/sh1.png" alt="" width="324" height="483" /></a></p>
<p style="text-align: left;">Well, I hope you guys have enjoyed the video tutorial.  I know that the audio is kind of low.  This is because I used my computer&#8217;s built in microphone and it&#8217;s not the greatest.  I have since purchased a new microphone (thanks again to all who have donated thus far) and future tutorials will have much better audio quality.  I would LOVE to hear your feedback on the videos.  I&#8217;m a total noob when it comes to screencasts and would love your <strong>constructive</strong> criticism.  Thank you all and Happy iCoding!</p>
<p style="text-align: left;">Download  the source code for this tutorial <a href="/wp-content/uploads/2008/09/tabbartutorial1.zip">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2008/09/28/uitabbar-iphone-tutorial/feed/</wfw:commentRss>
		<slash:comments>72</slash:comments>
		</item>
		<item>
		<title>iPhone Programming Tutorial &#8211; Creating a ToDo List Using SQLite Part 3</title>
		<link>http://icodeblog.com/2008/09/10/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-3/</link>
		<comments>http://icodeblog.com/2008/09/10/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-3/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 01:39:29 +0000</pubDate>
		<dc:creator><![CDATA[brandontreb]]></dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iphone programming]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[todo]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[uitableview]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=339</guid>
		<description><![CDATA[This is part 3 in our multipart series of creating a todo list for the iPhone.  For this, you must have completed the following tutorials.

<a title="Permanent Link to iPhone Programming Tutorial - Creating a ToDo List Using SQLite Part 1" rel="bookmark" href="/2008/08/19/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-1/">iPhone Programming Tutorial &#8211; Creating a ToDo List Using SQLite Part 1</a>
<a title="Permanent Link to iPhone Programming Tutorial - Creating a ToDo List Using SQLite Part 1" rel="bookmark" href="/2008/09/02/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-2/">iPhone Programming Tutorial &#8211; Creating a ToDo List Using SQLite  ...]]></description>
				<content:encoded><![CDATA[<p style="text-align: left;">This is part 3 in our multipart series of creating a todo list for the iPhone.  For this, you must have completed the following tutorials.</p>
<ul>
<li><a title="Permanent Link to iPhone Programming Tutorial - Creating a ToDo List Using SQLite Part 1" rel="bookmark" href="/2008/08/19/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-1/">iPhone Programming Tutorial &#8211; Creating a ToDo List Using SQLite Part 1</a></li>
<li><a title="Permanent Link to iPhone Programming Tutorial - Creating a ToDo List Using SQLite Part 1" rel="bookmark" href="/2008/09/02/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-2/">iPhone Programming Tutorial &#8211; Creating a ToDo List Using SQLite Part 2</a></li>
</ul>
<p>The focus of this tutorial will mainly be on viewing the todo items when selected.  I will also show you how to update the todo status.  This will require us to use interface builder.  When you are completed, you will be able to edit todos through an interface similar to this:</p>
<p style="text-align: center; "><a href="/wp-content/uploads/2008/09/screenshot11.png"><img class="size-full wp-image-390 aligncenter" title="screenshot1" src="/wp-content/uploads/2008/09/screenshot11.png" alt="" width="386" height="742" /></a></p>
<h2>Bringing Your Code Up To Speed</h2>
<p>For this tutorial, we will need to get the last variable from the todo database.  This is of course being the status variable.  If you recall, it&#8217;s a boolean value (1 for complete, 0 for in progress).  We need to get it from the database and associate it with the todo object.  First let&#8217;s create a property to hold this value.  Open todo.h and add the following code:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/todoh11.png"><img class="alignnone size-full wp-image-370" title="todoh1" src="/wp-content/uploads/2008/09/todoh11.png" alt="" width="393" height="329" /></a></p>
<p style="text-align: left;">So a few changes here&#8230;First there is the added NSInteger status.  This will be the property we associate with the status (complete or not) of the todo.  We also create a property from it.  Next, there is a BOOL property called &#8220;dirty&#8221;.  We will use this object to signify when a todo has been altered.  You will see how this comes into play when we implement the dehydrate method. Also, I have added 3 method signatures.  updateStatus will be the method called when we want to update our status variable.  Similarly, the updatePriority method will be called to update the priority.  Finally, we have added a dehydrate method.  This method should be familiar (or confusing) if you have messed with Apple&#8217;s books example.  Basically, it will be used to save the state of the todo to the database.  We will be calling this method on each todo item when the program exits.  I will show you how to do this in a little bit.</p>
<p style="text-align: left;">Be sure to add the status variable to the synthesize line.  Also, as we did before, we need to create a static sqlite3_stmt to hold the compiled dehydration statement.  Add the following code to Todo.m:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/synth11.png"><img class="alignnone size-full wp-image-382" title="synth1" src="/wp-content/uploads/2008/09/synth11.png" alt="" width="280" height="74" /></a></p>
<p style="text-align: left;">Now let&#8217;s implement the methods.  Add the following code:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/todom21.png"><img class="size-full wp-image-371 aligncenter" title="todom2" src="/wp-content/uploads/2008/09/todom21.png" alt="" width="500" height="379" /></a></p>
<p style="text-align: left;">The first two methods (udpateStatus and updatePriority) are pretty strait forward.  They update the status and the priority of the todo and then set the &#8220;dirty&#8221; property to 1.  This signifies that the todo has been altered and will need to be saved to the database.</p>
<p style="text-align: left;">Finally, there is the dehydrate method&#8230; We will call this method on each todo upon termination of the program.  If the todo is &#8220;dirty&#8221; meaning the dirty property was set to YES, we will need to save the new data to the database.  The database code should look pretty similar to code in previous tutorials.  First, we check to see if the dehydrate_statement is equal to nil.  If you recall, this will only happen the first time this method gets called.  Next we create the update statement and then bind our variables to each of the &#8220;?&#8221;&#8216;s.  Notice the ordering.  The numbers represent the question marks from left to right (1 being the first, 2 being the second, 3 being the third).  It took me quite some time to figure this out.  Finally, we execute the sqlite statement by calling sqlite3_step and then reset the statement.</p>
<p style="text-align: left;">The last thing we need to do to Todo.m is change the SELECT statement in the initWithPrimaryKey method to grab the &#8216;complete&#8217; field.  Update the code to look like the screenshot below:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/00-todom1.png"><img class="size-full wp-image-357 aligncenter" title="00-todom" src="/wp-content/uploads/2008/09/00-todom1.png" alt="" width="500" height="322" /></a></p>
<p style="text-align: left;">There are not really many changes.  The first change is the added status to the synthesize line.  Next, the sql statement was updated to read</p>
<p style="text-align: left;">SELECT text,priority,complete FROM todo WHERE pk=?</p>
<p style="text-align: left;">This allows us to get the &#8220;complete&#8221; field from the database.  Finally, there is the line &#8220;self.status = sqlite3_column_in(init_statement,2);&#8221;.  This is assigning the status property to the data at index 2 in the sql data array.  We can now use this field.</p>
<p style="text-align: left;">One thing we need to do for the navigation to function properly is add a title to our main view.  Open up rootViewController.m and add the following code to the viewDidLoad method:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/title1.png"><img class="alignnone size-full wp-image-381" title="title" src="/wp-content/uploads/2008/09/title1.png" alt="" width="175" height="16" /></a></p>
<h2>Create the Todo Detail View</h2>
<p>Now we are going to create the view that will display when the user selects the todo in the UITableView.  Go ahead and open up Interface Builder by selecting one of you existing nib (.xib) files.  Once it&#8217;s open add a new View by clicking <strong>File -&gt; New</strong> and select <strong>View.</strong> Drag the following controls.</p>
<ul>
<li>UITextView</li>
<li>UISegmentedControl &#8211; For this you will need to set the number of segments to 3.  You will also see a dropdown menu below this option.  Select each segment and fill in one of the priorities for the title.  Here is a screenshot. You should give a title to each (Low , Medium, High).
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/segmented-control1.png"><img class="alignnone size-full wp-image-340" title="segmented-control" src="/wp-content/uploads/2008/09/segmented-control1.png" alt="" width="287" height="708" /></a></p>
</li>
<li>UILabel &#8211; This will be used to display the status</li>
<li>UIButton &#8211; Users will click this button to update the status (Mark as complete)</li>
</ul>
<p>When you are done, your interface should look something like this (but probably better):</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/ibscreenshot1.png"><img class="alignnone size-full wp-image-369" title="ibscreenshot" src="/wp-content/uploads/2008/09/ibscreenshot1.png" alt="" width="320" height="502" /></a></p>
<p style="text-align: left;">I know that my interface doesn&#8217;t look the coolest.  I&#8217;m a programmer not a graphic designer&#8230; Ok save this view by pressing Command-S.  Make sure you are in your current projects directory.  Name it <strong>TodoViewController</strong> and press Save<strong>. </strong></p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/2-save1.png"><img class="size-full wp-image-343 aligncenter" title="2-save" src="/wp-content/uploads/2008/09/2-save1.png" alt="" width="500" height="392" /></a></p>
<p style="text-align: left;">It will then ask you if you want to add it to your project. Check the box next to the word todo and click Add.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/3-save1.png"><img class="alignnone size-full wp-image-344" title="3-save" src="/wp-content/uploads/2008/09/3-save1.png" alt="" width="431" height="290" /></a></p>
<p style="text-align: left;">Now close Interface Builder.  Next, we are going to add the viewController class and set up variables to interface with this view.</p>
<h2 style="text-align: left;">Create TodoViewController Class Files</h2>
<p>Click <strong>File -&gt; New File&#8230;</strong> Select <strong>UIViewController Subclass</strong> and click Next.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/08/14addviewcontrollerclass1.png"><img class="size-full wp-image-212 aligncenter" title="14addviewcontrollerclass" src="/wp-content/uploads/2008/08/14addviewcontrollerclass1.png" alt="" width="500" height="368" /></a></p>
<p style="text-align: left;">Name the file <strong>TodoViewController</strong> and make sure that the box that says &#8220;Also create TodoViewController.h&#8221; is checked and click Finish.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/4-viewcontroller1.png"><img class="size-full wp-image-345 aligncenter" title="4-viewcontroller" src="/wp-content/uploads/2008/09/4-viewcontroller1.png" alt="" width="500" height="368" /></a></p>
<p style="text-align: left;">Open up TodoViewController.h and add the following code.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/04-todoviewcontroller1.png"><img class="alignnone size-full wp-image-359" title="04-todoviewcontroller" src="/wp-content/uploads/2008/09/04-todoviewcontroller1.png" alt="" width="430" height="300" /></a></p>
<p style="text-align: left;">Basically, we are setting up Interface Builder Outlets for each of the UI components to be connected to.  Notice, the UIButton has an IBOutlet.  This is because we will need to update the text on the button depending on whether or not the todo is completed.  Also, I have an IBAction called updateStatus.  We will be connecting this to the button we created.  It will toggle the status (pending/complete) of a todo item.  Finally, we see the updatePriority method.  This method will be called when the user selects one of the priority segments in the UISegmentedControl. Next, open up TodoViewController.m and add the following synthesize code:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/synthtodoviewcontroller11.png"><img class="alignnone size-full wp-image-364" title="synthtodoviewcontroller1" src="/wp-content/uploads/2008/09/synthtodoviewcontroller11.png" alt="" width="374" height="22" /></a></p>
<p style="text-align: left;">This will allow us to get and set these variables.</p>
<p style="text-align: left;">Before we connect this code to the Interface, we need to implement the methods that will be called when the user presses the button to mark a todo as complete as well as when the user presses a segment in the UISegmentedControl.  Inside of TodoViewController add the following methods.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/todoviewcontrollerm1.png"><img class="size-full wp-image-368 aligncenter" title="todoviewcontrollerm" src="/wp-content/uploads/2008/09/todoviewcontrollerm1.png" alt="" width="500" height="229" /></a></p>
<p style="text-align: left;">Let&#8217;s go through this.  First we see the updateStatus method.  This gets called when a user presses the button to alter the status.  We basically check the current status of the todo (whether or not it&#8217;s completed) and depending on that, change the text to be displayed on the UIButton.  So, if the todo is not complete (in progress) and this button is pressed, the text will be changed from &#8220;Mark As Complete&#8221; to &#8220;Mark As In Progress&#8221;.  Finally, we call the updateStatus of the todo and pass the new value (1 or 0) to it.</p>
<p style="text-align: left;">Next we see the updatePriority method.  It simply reads the value of the UISegmentedControl by calling the selectedSegmentIndex method on it.  The next part looks a little messy.   There are 2 reasons that reason we can&#8217;t just pass the value of the UISegmentedControl directly to the method.  The first is, the UISegmentedControl is ordered in acending order (1, 2, 3&#8230;), but our priorities are in descending order (3 = low, 2 = medium, 1 = high).  This is where the &#8220;2 &#8211; priority&#8221; comes from.  Next, UISegmented controls are &#8220;0 indexed&#8221; meaning the indices start at 0 and increment from there.  So we need to add a &#8220;+1&#8243; to the index as our todo priorities start at 1.</p>
<p style="text-align: left;">Now we need to connect the UI Components in Interface Builder to this code.  Double click on TodoViewController.xib to open it in Interface Builder.</p>
<h2 style="text-align: left;">Connecting UI Components To Code</h2>
<p>We first need to associate this view with the class we just created.  In the Interface Builder, click on the File&#8217;s Owner object.  Next click <strong>Tools -&gt; Identity Inspector</strong>.  You should see a drop-down next to class.  Select TodoViewController from this list and you will see the variables we just created appear in the boxes below.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/07-files-owner1.png"><img class="size-full wp-image-349 aligncenter" title="07-files-owner" src="/wp-content/uploads/2008/09/07-files-owner1.png" alt="" width="305" height="287" /></a></p>
<p style="text-align: left;">This is what the Identity window should look like after you have selected TodoViewController.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/todoviewcontrollerfilesowner1.png"><img class="alignnone size-full wp-image-380" title="todoviewcontrollerfilesowner" src="/wp-content/uploads/2008/09/todoviewcontrollerfilesowner1.png" alt="" width="287" height="708" /></a></p>
<p style="text-align: left;">Now that the class is associated, we can begin connecting the components.  We will start by connecting the view.  Click on the top of your view window to select the view itself (make sure you haven&#8217;t selected any of the UI components).  Click <strong>Tools -&gt; Connections Inspector</strong>.  Next to where is says &#8220;New Referencing Outlet&#8221; click in the circle and drag it to the &#8220;File&#8217;s Owner&#8221; object and release it.  The word &#8220;view&#8221; should pop up.  Click on the word view.  It should now look like this.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/08-view-connect1.png"><img class="size-full wp-image-350 aligncenter" title="08-view-connect" src="/wp-content/uploads/2008/09/08-view-connect1.png" alt="" width="287" height="708" /></a></p>
<p style="text-align: left;">Now repeat these steps for each of the components (UITextView, UISegmentedControl, UILabel, UIButton) connecting each to the &#8220;File&#8217;s Owner Object&#8221;.   Instead of the word &#8220;view&#8221; popping up, you should see the variable name for the corresponding variable that you want to connect the component to.   So for the UITextView, you should see the word &#8220;todoText&#8221; appear when you drag it to the File&#8217;s Owner object.</p>
<p style="text-align: left;">We need to connect the UIButton to the updateStatus method we created.  To do this click inside the &#8220;Touch up inside&#8221; circle and drag it to the &#8220;File&#8217;s Owner&#8221; object.  You should see the text &#8220;updateStatus&#8221; appear.  Click on it.  If all goes well it should look like this.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/uibutton11.png"><img class="alignnone size-full wp-image-362" title="uibutton1" src="/wp-content/uploads/2008/09/uibutton11.png" alt="" width="287" height="708" /></a></p>
<p style="text-align: left;">The last thing we need to do inside of Interface Builder is connect the UISegmentedControl.  Click on it in your view and then click <strong>Tools -&gt; Connections Inspector&#8230;</strong> Click on the circle next to the &#8220;Value Changed&#8221; method and drag it to the &#8220;File&#8217;s Owner&#8221; object.  You will see the method updatePriority popup.  Go ahead and click on it.  Your window for the UISegmentedControl should now look like this:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/uisegementedcontrol11.png"><img class="alignnone size-full wp-image-366" title="uisegementedcontrol1" src="/wp-content/uploads/2008/09/uisegementedcontrol11.png" alt="" width="287" height="708" /></a></p>
<p style="text-align: left;">Now, let&#8217;s display this view when a row is selected.  Close Interface Builder and open up RootViewController.h and add the following code:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/11-rootviewcontroller2.png"><img class="size-full wp-image-354 aligncenter" title="11-rootviewcontroller" src="/wp-content/uploads/2008/09/11-rootviewcontroller2.png" alt="" width="352" height="149" /></a></p>
<p style="text-align: left;">We need a variable to associate with the TodoViewController that we will be transitioning to.  Next, open up RootViewController.m and add the following code to synthesize this property.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/12-synth1.png"><img class="size-full wp-image-355 aligncenter" title="12-synth" src="/wp-content/uploads/2008/09/12-synth1.png" alt="" width="133" height="21" /></a></p>
<h2 style="text-align: left;">Keeping the UITableView Up To Date</h2>
<p style="text-align: left;">Whenever a todo item is altered (status or priority) the UITableView needs to be updated with the new changes.  Add the following code to the viewWillAppear.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/rootviewcontrollermwillapprea1.png"><img class="size-full wp-image-372 aligncenter" title="rootviewcontrollermwillapprea" src="/wp-content/uploads/2008/09/rootviewcontrollermwillapprea1.png" alt="" width="246" height="65" /></a></p>
<p style="text-align: left;">The line [self.tableView reloadData] reloads the table data every time the view appears (or reappears).  This will ensure that our table is always up to date.</p>
<p style="text-align: left;">Now add the following code to the didSelectRowAtIndex method:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/didselectrowatindex1.png"><img class="size-full wp-image-373 aligncenter" title="didselectrowatindex" src="/wp-content/uploads/2008/09/didselectrowatindex1.png" alt="" width="500" height="341" /></a></p>
<p style="text-align: left;">This is quite a bulky method with a lot of familiar code.  First, we get a handle to the appDelegate and the todo object that was selected.  Next, we push the todoView (the view you created in interface builder) on to the viewController stack to transition to it.  After that, we are setting some of the properties of the view.  The title is set to the text of the todo (it will get truncated if it is too long) and the UITextView is also set to the todo text.  Next, we are translating our priority to an index for the UISegmentedView.  I explained why this was necessary above.  Then the index of the UISegmentedControl is set by using the setSelectedSegmentIndex method.  Finally, we set the text of the button and label based on the status of the todo.</p>
<p style="text-align: left;">The very last thing we need to do is tell the application to save itself when it closes.  Open up todoAppDelegate.m and add the following code to the applicationWillTerminate method:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/09/applicationwillterminate1.png"><img class="size-full wp-image-374 aligncenter" title="applicationwillterminate" src="/wp-content/uploads/2008/09/applicationwillterminate1.png" alt="" width="388" height="64" /></a></p>
<p style="text-align: left;">If you ask me, this is some freakin sweet functionality.  The method &#8220;makeObjectsPerformSelector&#8221; is a built in method on an NSArray.  It basically loops over every object in the array, calling the method you pass in to it on each one.  It&#8217;s like doing a for loop and calling the todo[x].dehydrate method for each todo.  Only this is much cleaner.  So, to reiterate, this method will call the dehydrate method on each todo.  If the todo is &#8220;dirty&#8221; meaning it was altered, it will be saved to the database, otherwise the dehydrate method will do nothing.</p>
<p style="text-align: left;">* One thing to note.  The applicationWillTerminate method will not be called if you quit the simulator while the application is running.  To make sure it gets called (and the todo data gets saved) make sure you press the home button on the simulator after you make alterations to the todos.  If you simply press Apple-q and quit the simulator while inside of the todo program, no data will be saved and you will post angry comments on my site telling me that my tutorial is wrong.</p>
<p style="text-align: left;">Click Build and Go and just sit back and enjoy the magic of rock! I mean XCode&#8230;</p>
<p style="text-align: left;">When you select a todo item, your screen should look something like this:</p>
<p style="text-align: center; "><a href="/wp-content/uploads/2008/09/screenshot11.png"><img class="size-full wp-image-390 aligncenter" title="screenshot1" src="/wp-content/uploads/2008/09/screenshot11.png" alt="" width="386" height="742" /></a></p>
<p style="text-align: left;">Well, that concludes part 3 of our series.  Join me next time, when I will show you how to add and delete todos from the SQLite database. If you have any comments or questions, feel free to leave them in the comments section.  I would love to hear them.  Please <a href="http://feeds.feedburner.com/icodeblog">subscribe to the RSS feed</a> if you want to be automatically notified of new tutorials.  If you get lost at any point, you can download the sample code for this tutorial <a href="/wp-content/uploads/2008/09/todo-part-31.zip">here</a>.</p>
<p style="text-align: left;">Happy iCoding!</p>
<p style="text-align: left;">
<p style="text-align: left;">
]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2008/09/10/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-3/feed/</wfw:commentRss>
		<slash:comments>68</slash:comments>
		</item>
		<item>
		<title>iPhone Programming Tutorial &#8211; Beginner Interface Builder Hello World</title>
		<link>http://icodeblog.com/2008/07/29/iphone-programming-tutorial-beginner-interface-builder-hello-world/</link>
		<comments>http://icodeblog.com/2008/07/29/iphone-programming-tutorial-beginner-interface-builder-hello-world/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 15:29:12 +0000</pubDate>
		<dc:creator><![CDATA[brandontreb]]></dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[iphone code]]></category>
		<category><![CDATA[iphone tutorial]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=71</guid>
		<description><![CDATA[digg_url = 'http://digg.com/apple/iPhone_Programming_Tutorial_Beginner_Interface_Builder';
In my last tutorial <a href="/2008/07/26/iphone-programming-tutorial-hello-world/">UITableView Hello World</a> I said that there are many ways to write a &#8220;Hello World&#8221; tutorial for the iPhone.  Here is one using Interface Builder. Last time, I demonstrated a simple way to populate one cell in a UITableView with some text.  Today&#8217;s tutorial is even simpler.  I will show you how to work with Interface Builder to create a simple layout for you application.  In fact, you won&#8217;t  ...]]></description>
				<content:encoded><![CDATA[<p><script>digg_url = 'http://digg.com/apple/iPhone_Programming_Tutorial_Beginner_Interface_Builder';</script><script src="http://digg.com/api/diggthis.js"></script></p>
<p>In my last tutorial <a href="/2008/07/26/iphone-programming-tutorial-hello-world/">UITableView Hello World</a> I said that there are many ways to write a &#8220;Hello World&#8221; tutorial for the iPhone.  Here is one using Interface Builder. Last time, I demonstrated a simple way to populate one cell in a UITableView with some text.  Today&#8217;s tutorial is even simpler.  I will show you how to work with Interface Builder to create a simple layout for you application.  In fact, you won&#8217;t write any code at all! In my next tutorial, I will detail how to interface with your UI components in code.</p>
<p>In this tutorial you will learn:</p>
<ul>
<li><a href="#new-window-based-project">Create a New View Based Project</a></li>
<li><a href="#iphone-simulator">Opening the iPhone Simulator</a></li>
<li><a href="#interface-builder">Adding UI Elements to your home screen</a></li>
<li><a href="#executing-the-code">Executing the code</a></li>
</ul>
<h2><a name="new-window-based-project">Create a New View Based Project</a></h2>
<p>Let&#8217;s start by opening up XCode and Creating a new View-Based Application.  Do this by clicking on<br />
<strong>File &gt; New Project. </strong>Make sure that <strong>Application </strong>is highlighted under <strong>iPhone OS</strong> and select <strong>View-Based Application. </strong>Name this project HelloWorldViews.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/07/screenshot_012.png"><img class="size-full wp-image-72 aligncenter" title="screenshot_01" src="/wp-content/uploads/2008/07/screenshot_012.png" alt="" width="500" height="368" /></a></p>
<p style="text-align: left;">So at this point, Apple has added some default files to get us started.  They have added the main window for us to edit along with the code to launch the window.  Now in iPhone terms, each window is called a <strong>View</strong>.  Since you can only see one view at a time, you will need to create a new view for each screen in your application.  In this tutorial, we will be sticking to editing the view Apple has provided us.  In later tutorials, I will go into how to add new views and transition between them.  Go ahead and click <strong>Build and Go</strong>.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/07/buildandgo1.png"><img class="size-full wp-image-36 aligncenter" title="Build And Go" src="/wp-content/uploads/2008/07/buildandgo1.png" alt="" width="500" height="58" /></a></p>
<p style="text-align: left;">
<h2 style="text-align: left;"><a name="iphone-simulator">Opening the iPhone Simulator</a></h2>
<p style="text-align: left;">The program should compile and launch the <strong>iPhone Simululator</strong>. Your screen should look something like this.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/07/screenshot_022.png"><img class="size-full wp-image-73 aligncenter" title="screenshot_02" src="/wp-content/uploads/2008/07/screenshot_022.png" alt="" width="386" height="742" /></a></p>
<p style="text-align: left;">Not very interesting right? Excuse my crappy screenshot.  So let&#8217;s add some UI components to our view to make it more interesting.  To do this we will be editing HelloWorldViewsViewController.xib . A file with the .xib extension is known as a nib file.  These files open with Interface Builder and are where you define the look and feel of your application.  Apple is nice enough to have provided us with one.</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/07/screenshot_051.png"><img class="size-full wp-image-75 aligncenter" title="screenshot_05" src="/wp-content/uploads/2008/07/screenshot_051.png" alt="" width="264" height="82" /></a></p>
<h2 style="text-align: left;"><a name="interface-builder">Adding UI Elements to You Home Screen</a></h2>
<p style="text-align: left;">Once you open Interface Builder, you should see a few different windows&#8230; You should see a blank window that has the same dimentions as the iPhone that says <strong>View </strong>up in the top.  If not click the <strong>View</strong> icon in the smaller box.  This is the main window we will be editing.</p>
<p style="text-align: left;">To the right, you should see a tool box that contains many different UI components.  Most of them should look familiar if you have ever used an iPhone application.  So let&#8217;s add a few of them to our view.  Just click on the one&#8217;s you want and drag them on to your view. Make sure you at least use a <strong>Label</strong>.  For this tutorial, I have used a <strong>Label, Search Bar, </strong>and a <strong>Tab Bar</strong>.  Notice when you drag the search bar and tab bar onto the view, they size correctly to the screen.  Also, if you move the items around, you will see blue lines that guide you.  These are in place to help you line up components and center them.</p>
<p style="text-align: left;">After you have added the label, click on it.  Now let&#8217;s open the <strong>Attributes Inspector</strong> to change the text of the label.  To do this click <strong>Tools &gt; Attributes Inspector.</strong> At the top of the Attributes Inspector you should see a box labeled <strong>Text. </strong>If you don&#8217;t click on the label again to select it.  Put whatever you would like the label to say in that box.  I put &#8220;Hello World&#8221;.  You can update other properties of the label including color and font using the Attributes Inspector.  You may need to resize the Label to accommodate your new text.  To do this click on the label and you will see little boxes around it that you can drag to resize the text area.</p>
<p style="text-align: left;">After you are done, your interface should look something like this:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/07/screenshot_071.png"><img class="size-full wp-image-76 aligncenter" title="screenshot_07" src="/wp-content/uploads/2008/07/screenshot_071.png" alt="" width="320" height="482" /></a></p>
<p style="text-align: left;">Now press Apple-S to save this file.  We are done with Interface Builder so you can close it.  Your application should now be ready to execute.</p>
<h2 style="text-align: left;"><a name="executing-the-code">Executing the Code</a></h2>
<p style="text-align: left;">Go ahead and click <strong>Build and Go</strong> again to launch the <strong>iPhone Simulator.</strong> Your screens should look something like this:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2008/07/screenshot_082.png"><img class="size-full wp-image-77 aligncenter" title="screenshot_08" src="/wp-content/uploads/2008/07/screenshot_082.png" alt="" width="386" height="742" /></a></p>
<p style="text-align: left;">There you have it! A simple iPhone application without writing a line of code. If you click in the search box, the iPhone will automatically pull up the keyboard.  Thank you for reading this tutorial and I hope that you have learned something.  In my next tutorial, I will show you how to use code to interface with our UI components.  If you have any questions, feel free to leave them in the comments. Happy iCoding!</p>
]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2008/07/29/iphone-programming-tutorial-beginner-interface-builder-hello-world/feed/</wfw:commentRss>
		<slash:comments>72</slash:comments>
		</item>
	</channel>
</rss>
