<?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 Tutorial &#124; iPhone iOS4 iPad SDK Development &#38; Programming Blog &#187; Picker Component</title>
	<atom:link href="http://www.edumobile.org/iphone/tag/picker-component/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.edumobile.org/iphone</link>
	<description></description>
	<lastBuildDate>Wed, 25 Jan 2012 09:42:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Display Datepicker SingleComponentpicker and Doublecomponentpicker with each of the tabbar in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/display-datepicker-singlecomponentpicker-and-doublecomponentpicker-with-each-of-the-tabbar-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/display-datepicker-singlecomponentpicker-and-doublecomponentpicker-with-each-of-the-tabbar-in-iphone/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 14:50:55 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[Display Datepicker SingleComponentpicker and Doublecomponentpicker with each of the tabbar in iPhone]]></category>
		<category><![CDATA[iphone development]]></category>
		<category><![CDATA[Picker Component]]></category>
		<category><![CDATA[Tabbar example]]></category>

		<guid isPermaLink="false">http://edumobile.org/iphone/?p=1338</guid>
		<description><![CDATA[We will see how to display Datepicker, SingleComponent picker and Doublecomponent picker using the Tab Bar controller.]]></description>
			<content:encoded><![CDATA[<p>We will see how to display Datepicker, SingleComponent picker and Doublecomponent picker using the Tab Bar controller.</p>
<p><strong>Step 1: </strong>Create aTab bar Application using template . Name the project  &#8221;TabBarWithPicker&#8221;.</p>
<p><strong>Step 2: </strong>Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.</p>
<p><strong>Step 3: </strong>Expand classes and notice Interface Builder created the FirstViewController class for you. Expand Resources and notice the template generated a separate nib, SecondView.xib, for the TabBarWithPicker.</p>
<p><strong>Step 4:</strong> Now we’ll add UIViewController class to the project. Choose New file -&gt; Select cocoa touch classes group and then select UIViewController . Give the name of the class SingleComponentPickerViewController. Create one more UIViewController class file and corresponding .xib file ,give the name DoubleComponentPickerViewController.</p>
<p><strong>Step 5:</strong> In the FirstViewController.h file we added UIDatePicker class that implements an object for multiple rotating wheels to allow users to select date and a method an IBAction. make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="kw1">@interface</span> FirstViewController <span class="sy0">:</span> UIViewController <br />
&lt;UIPickerViewDataSource , UIPickerViewDelegate&gt;<span class="br0">&#123;</span><br />
&nbsp; IBOutlet UIDatePicker <span class="sy0">*</span>datePicker;<br />
<span class="br0">&#125;</span><br />
&nbsp; <span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic , retain<span class="br0">&#41;</span> UIDatePicker <span class="sy0">*</span>datePicker;<br />
&nbsp; <span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>buttonPressed;</div>
</div>
<p><strong>Step 6:</strong> Now double click your MainWindow.xib file and open it to the Interface Builder. Open the TabBar Controller and drag the Tab Bar Item from the library and place it below of the Tab Bar(See the figure below). Now dragDate Picker from the library and place it to the view window, and also drag Round Rect from the library and place it to the below of the Date Picker. Select DatePicker from the tab bar and bring up Connection Inspector and now drag from the datePicker to the picker. Select Round Rect button and bring up Connection Inspector then drag from TouchUpInside to the File&#8217;s Owner icon, select buttonPressed: action. Now save the MainWindow.xib file and go back to the Xcode.</p>
<p><a href="http://edumobile.org/iphone/wp-content/uploads/2010/03/IB_datepicker.jpg"><img class="alignnone size-medium wp-image-1339" title="IB_datepicker" src="http://edumobile.org/iphone/wp-content/uploads/2010/03/IB_datepicker-190x300.jpg" alt="" width="190" height="300" /></a></p>
<p><strong>Step 7:</strong> In the FirstViewController.m make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>buttonPressed<span class="br0">&#123;</span><br />
&nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/"><span class="kw5">NSDate</span></a> <span class="sy0">*</span>selected <span class="sy0">=</span> <span class="br0">&#91;</span>datePicker date<span class="br0">&#93;</span>;<br />
&nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>message <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> alloc<span class="br0">&#93;</span> initWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;The date and time is %@&quot;</span>,selected<span class="br0">&#93;</span>;<br />
&nbsp; UIAlertView <span class="sy0">*</span>alert <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIAlertView alloc<span class="br0">&#93;</span><br />
&nbsp; initWithTitle<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;Date and Time selected&quot;</span> message<span class="sy0">:</span>message delegate<span class="sy0">:</span><span class="kw2">nil</span> &nbsp; cancelButtonTitle<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;YES&quot;</span> otherButtonTitles<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;</p>
<p>&nbsp; <span class="br0">&#91;</span>alert show<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>alert release<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>message release<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p>&nbsp; <span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad <span class="br0">&#123;</span><br />
&nbsp; <span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
&nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/"><span class="kw5">NSDate</span></a> <span class="sy0">*</span>now <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/"><span class="kw5">NSDate</span></a> alloc<span class="br0">&#93;</span> init<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>datePicker setDate<span class="sy0">:</span>now animated<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>now release<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></div>
</div>
<p><strong>Step 8: </strong>Single click the SingleComponentPickerViewController.h file in the classes folder and open it to the Xcode.This controller class will act as a both DataSource and Delegate for its Picker. So we need to implement datasource and delegate protocol. Also need to declare an IBOutlet and an Action .Add the following code in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="kw1">@interface</span> SingleComponentPickerViewController <span class="sy0">:</span> UIViewController<br />
&nbsp; &lt;UIPickerViewDataSource , UIPickerViewDelegate&gt;<br />
&nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp;IBOutlet UIPickerView <span class="sy0">*</span>singlePicker;<br />
&nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span class="kw5">NSArray</span></a> <span class="sy0">*</span>pickerData;<br />
<span class="br0">&#125;</span><br />
&nbsp; <span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic , retain<span class="br0">&#41;</span> UIPickerView <span class="sy0">*</span>singlePicker;<br />
&nbsp; <span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic , retain<span class="br0">&#41;</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span class="kw5">NSArray</span></a> <span class="sy0">*</span>pickerData;</p>
<p>&nbsp; <span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>buttonPressed1;</div>
</div>
<p><strong>Step 9:</strong> Open the SecondView.xib file in the Interface Builder. Double click your view icon open the view window, first drag the Picker view from the library and place it to the view window (See the figure below). Select the picker and bring up connection inspector, you will see the first two items are Datasource and Delegate. Drag from the circle next to DataSource to File&#8217;s Owner.Then drag again from the circle next to Delegate to the File&#8217;s Owner. Next drag Round Rect button from the library and place it to the view window and give the title Select. Now select the Select button and bring up connection inspector and drag from the Touch Up Inside to the File&#8217;s Owner and select buttonPressed1: action. Save the nib file,close it and go back to the Xcode.</p>
<p><a href="http://edumobile.org/iphone/wp-content/uploads/2010/03/IB_secView.jpg"><img class="alignnone size-medium wp-image-1340" title="IB_secView" src="http://edumobile.org/iphone/wp-content/uploads/2010/03/IB_secView-193x300.jpg" alt="" width="193" height="300" /></a></p>
<p><strong>Step 10:</strong> Now open the MainWindow.xib file in the Interface Builder. Load the secondView.xib file in the MainWindow.xib . Select the SingleCompoPicker from the tab bar and bring up Attribute inspector change the NIB name into SecondView and bring up Identity Inspector change the class name into SingleComponentPickerViewController. Save the nib file , close it and go back to the Xcode.</p>
<p><strong>Step 11:</strong> Open the SingleComponentPickerViewController.m file and make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>buttonPressed1<br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; NSInteger row <span class="sy0">=</span> <span class="br0">&#91;</span>singlePicker selectedRowInComponent<span class="sy0">:</span>0<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>selected <span class="sy0">=</span> <span class="br0">&#91;</span>pickerData objectAtIndex<span class="sy0">:</span>row<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>title <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> alloc<span class="br0">&#93;</span> initWithFormat<span class="sy0">:</span><br />
&nbsp; &nbsp; <span class="co3">@</span><span class="st0">&quot;you selected %@!&quot;</span>, selected<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; UIAlertView <span class="sy0">*</span>alert <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIAlertView alloc<span class="br0">&#93;</span> initWithTitle<span class="sy0">:</span>title<br />
&nbsp; &nbsp; message <span class="sy0">:</span> <span class="co3">@</span><span class="st0">&quot;Thank you for choosing.&quot;</span><br />
&nbsp; &nbsp; delegate<span class="sy0">:</span><span class="kw2">nil</span><br />
&nbsp; &nbsp; cancelButtonTitle <span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;Welcome&quot;</span><br />
&nbsp; &nbsp; otherButtonTitles <span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>alert show<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>alert release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>title release<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p>&nbsp; <span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span class="kw5">NSArray</span></a> <span class="sy0">*</span>array <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span class="kw5">NSArray</span></a> alloc<span class="br0">&#93;</span> &nbsp; &nbsp; initWithObjects<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;iPhone&quot;</span>,<span class="co3">@</span><span class="st0">&quot;iPad&quot;</span>,<span class="co3">@</span><span class="st0">&quot;iPod&quot;</span>,<span class="co3">@</span><span class="st0">&quot;iMac&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Mac&quot;</span>,<br />
&nbsp; &nbsp;<span class="co3">@</span><span class="st0">&quot;iBook&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Safari&quot;</span>,<span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; self.pickerData <span class="sy0">=</span> array;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>array release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 12:</strong> Open the DoubleComponentPickerViewController.h, we&#8217;ll define here a picker with two components or wheels,each wheel will be independent of the other wheel. Define two constants that will represent the two components. Components are assigned numbers and declare DataSource and Delegate for its Picker. Also need to declare an IBOutlet and an Action .Now make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#define kFillingComponent &nbsp;0</span><br />
&nbsp; &nbsp;<span class="co1">#define kBreadComponent &nbsp;1</span></p>
<p>&nbsp; <span class="kw1">@interface</span> DoubleComponentPickerViewController <span class="sy0">:</span> UIViewController<br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp;IBOutlet UIPickerView <span class="sy0">*</span>doublePicker;<br />
&nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span class="kw5">NSArray</span></a> <span class="sy0">*</span>fillingTypes;<br />
&nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span class="kw5">NSArray</span></a> <span class="sy0">*</span>breadTypes;<br />
<span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> &nbsp;UIPickerView <span class="sy0">*</span>doublePicker;<br />
&nbsp; <span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span class="kw5">NSArray</span></a> <span class="sy0">*</span>fillingTypes;<br />
&nbsp; <span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span class="kw5">NSArray</span></a> <span class="sy0">*</span>breadTypes;</p>
<p>&nbsp; <span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>buttonPressed2;</div>
</div>
<p><strong>Step 13:</strong> Open the DoubleComponentPickerViewController.xib file in the Interface Builder. Double click your view icon open the view window, first drag the Picker view from the library and place it to the view window. Select the picker and bring up connection inspector, you will see the first two items are Datasource and Delegate. Drag from the circle next to DataSource to File&#8217;s Owner.Then drag again from the circle next to Delegate to the File&#8217;s Owner. Next drag Round Rect button from the library and place it to the view window and give the title Select. Now select the Select button and bring up connection inspector and drag from the Touch Up Inside to the File&#8217;s Owner and select buttonPressed2: action. Save the nib file,close it and go back to the Xcode.</p>
<p><strong>Step 14:</strong> Now open the MainWindow.xib file in the Interface Builder. Load the DoubleComponentPickerViewController file in the MainWindow.xib . Select the DoubleCompoPicker from the tab bar and bring up Attribute inspector change the NIB name into DoubleComponentPickerViewController and bring up Identity Inspector change the class name into DoubleComponentPickerViewController. Save the nib file , close it and go back to the Xcode.</p>
<p><strong>Step 15: </strong>Now make the following changes in the DoubleComponentPickerViewController.m file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>buttonPressed2<br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp;NSInteger breadRow <span class="sy0">=</span> <span class="br0">&#91;</span>doublePicker selectedRowInComponent<span class="sy0">:</span><br />
&nbsp; &nbsp;kBreadComponent<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;NSInteger fillingRow <span class="sy0">=</span> <span class="br0">&#91;</span>doublePicker selectedRowInComponent<span class="sy0">:</span><br />
&nbsp; &nbsp;kFillingComponent<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>bread <span class="sy0">=</span> <span class="br0">&#91;</span>breadTypes objectAtIndex<span class="sy0">:</span>breadRow<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>filling <span class="sy0">=</span> <span class="br0">&#91;</span>fillingTypes objectAtIndex<span class="sy0">:</span>fillingRow<span class="br0">&#93;</span>;</p>
<p>&nbsp; &nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>message <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> alloc<span class="br0">&#93;</span> initWithFormat<span class="sy0">:</span><br />
&nbsp; &nbsp;<span class="co3">@</span><span class="st0">&quot;Your %@ on %@ bread will be right up.&quot;</span>,filling, bread<span class="br0">&#93;</span>;</p>
<p>&nbsp; &nbsp;UIAlertView <span class="sy0">*</span>alert <span class="sy0">=</span><span class="br0">&#91;</span><span class="br0">&#91;</span>UIAlertView alloc<span class="br0">&#93;</span> initWithTitle<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;Thank you for &nbsp; your order&quot;</span> message<span class="sy0">:</span>message delegate<span class="sy0">:</span><span class="kw2">nil</span> cancelButtonTitle<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;Great!&quot;</span> &nbsp; otherButtonTitles<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;<span class="br0">&#91;</span>alert show<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;<span class="br0">&#91;</span>alert release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;<span class="br0">&#91;</span>message release<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p>&nbsp;<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad <span class="br0">&#123;</span><br />
&nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span class="kw5">NSArray</span></a> <span class="sy0">*</span>breadArray <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span class="kw5">NSArray</span></a> alloc<span class="br0">&#93;</span> initWithObjects<span class="sy0">:</span><br />
&nbsp; <span class="co3">@</span><span class="st0">&quot;White&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Whole Wheat&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Rye&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Sourdough&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Seven Grain&quot;</span>, <span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
&nbsp; self.breadTypes <span class="sy0">=</span> breadArray;<br />
&nbsp; <span class="br0">&#91;</span>breadArray release<span class="br0">&#93;</span>;</p>
<p>&nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span class="kw5">NSArray</span></a> <span class="sy0">*</span>fillingArray <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span class="kw5">NSArray</span></a> alloc<span class="br0">&#93;</span> initWithObjects<span class="sy0">:</span><br />
&nbsp; <span class="co3">@</span><span class="st0">&quot;Chicken&quot;</span>,<span class="co3">@</span><span class="st0">&quot; Butter&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Mutton&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Salad&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Beef&quot;</span>,<br />
&nbsp; <span class="co3">@</span><span class="st0">&quot;Vegetable&quot;</span>,<span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
&nbsp; self.fillingTypes <span class="sy0">=</span> fillingArray;<br />
&nbsp; <span class="br0">&#91;</span>fillingArray release<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p>&nbsp;<span class="sy0">-</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>numberOfComponentsInPickerView<span class="sy0">:</span><span class="br0">&#40;</span>UIPickerView <span class="sy0">*</span><span class="br0">&#41;</span>pickerView<br />
&nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw1">return</span> <span class="nu0">2</span>;<br />
<span class="br0">&#125;</span></p>
<p>&nbsp; <span class="sy0">-</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>pickerView<span class="sy0">:</span><span class="br0">&#40;</span>UIPickerView <span class="sy0">*</span><span class="br0">&#41;</span>pickerView<br />
&nbsp; numberOfRowsInComponent<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>component<br />
&nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span>component <span class="sy0">==</span> kBreadComponent<span class="br0">&#41;</span><br />
&nbsp; &nbsp;<span class="kw1">return</span><span class="br0">&#91;</span>self.breadTypes count<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;<span class="kw1">return</span><span class="br0">&#91;</span>self.fillingTypes count<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p>&nbsp; <span class="sy0">-</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>pickerView<span class="sy0">:</span><span class="br0">&#40;</span>UIPickerView <span class="sy0">*</span><span class="br0">&#41;</span>pickerView<br />
&nbsp; titleForRow<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>row<br />
&nbsp; forComponent<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>component<br />
&nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span>component <span class="sy0">==</span> kBreadComponent<span class="br0">&#41;</span><br />
&nbsp; &nbsp;<span class="kw1">return</span> <span class="br0">&#91;</span>self. breadTypes objectAtIndex<span class="sy0">:</span>row<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;<span class="kw1">return</span> <span class="br0">&#91;</span>self.fillingTypes objectAtIndex<span class="sy0">:</span>row<span class="br0">&#93;</span>;<br />
&nbsp;<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 16:</strong> Now compile and run the application.</p>
<p><a href="http://edumobile.org/iphone/wp-content/uploads/2010/03/output1.jpg"><img class="alignnone size-medium wp-image-1341" title="output1" src="http://edumobile.org/iphone/wp-content/uploads/2010/03/output1-155x300.jpg" alt="" width="155" height="300" /></a></p>
<p>You can <strong>downloaded SourceCode</strong> from here  <a href='http://edumobile.org/iphone/wp-content/uploads/2010/03/TabBarWithPicker-2.zip'>TabBarWithPicker 2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/display-datepicker-singlecomponentpicker-and-doublecomponentpicker-with-each-of-the-tabbar-in-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

