<?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; iPhone Beginner Tutorials</title>
	<atom:link href="http://www.edumobile.org/iphone/category/iphone-beginner-tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.edumobile.org/iphone</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 11:17:27 +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>ToolBar application in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-interface-builder/toolbar-application-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-interface-builder/toolbar-application-in-iphone/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 09:19:15 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Interface Builder]]></category>
		<category><![CDATA[ToolBar Application]]></category>
		<category><![CDATA[ToolBar application in iPhone]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3174</guid>
		<description><![CDATA[This is the very simple ToolBar application.In this application we will see how to tool bar add in the application. So let see how it will worked.]]></description>
			<content:encoded><![CDATA[<p>This is the very simple ToolBar application.In this application we will see how to tool bar add in the application. So let see how it will worked. My last post you can find out from here.</p>
<p><strong>Step 1: </strong>Open the Xcode, Create a new project using Navigation Base application. Give the application “ToolBar”.</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> We need to add one UIViewController subclass in the project. Select project -&gt; New file -&gt; select UIViewController subclass . Give the file name &#8220;NextViewController&#8221;. Create the NextViewController.xib file also.</p>
<p><strong>Step 4:</strong> Open the ToolBarViewController.m file and make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;RootViewController.h&quot;</span><br />
<span class="co1">#import &quot;NextViewController.h&quot;</span></p>
<p><span class="kw1">@implementation</span> RootViewController</p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
self.navigationItem.rightBarButtonItem <span class="sy0">=</span> self.editButtonItem;<br />
self.title <span class="sy0">=</span> <span class="co3">@</span><span class="st0">&quot;ToolBar Application&quot;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewWillAppear<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>animated<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewWillAppear<span class="sy0">:</span>animated<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidAppear<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>animated<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidAppear<span class="sy0">:</span>animated<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewWillDisappear<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>animated<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewWillDisappear<span class="sy0">:</span>animated<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidDisappear<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>animated<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidDisappear<span class="sy0">:</span>animated<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="coMULTI">/*<br />
// Override to allow orientations other than the default portrait orientation.<br />
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {<br />
// Return YES for supported orientations.<br />
return (interfaceOrientation == UIInterfaceOrientationPortrait);<br />
}<br />
*/</span></p>
<p><span class="co2">// Customize the number of sections in the table view.</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>numberOfSectionsInTableView<span class="sy0">:</span><span class="br0">&#40;</span>UITableView <span class="sy0">*</span><span class="br0">&#41;</span>tableView<br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> <span class="nu0">5</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>tableView<span class="sy0">:</span><span class="br0">&#40;</span>UITableView <span class="sy0">*</span><span class="br0">&#41;</span>tableView numberOfRowsInSection<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>section<br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> <span class="nu0">1</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="co2">// Customize the appearance of table view cells.</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span>UITableViewCell <span class="sy0">*</span><span class="br0">&#41;</span>tableView<span class="sy0">:</span><span class="br0">&#40;</span>UITableView <span class="sy0">*</span><span class="br0">&#41;</span>tableView cellForRowAtIndexPath<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span class="kw5">NSIndexPath</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>indexPath<br />
<span class="br0">&#123;</span><br />
<span class="kw4">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>CellIdentifier <span class="sy0">=</span> <span class="co3">@</span><span class="st0">&quot;Cell&quot;</span>;</p>
<p>UITableViewCell <span class="sy0">*</span>cell <span class="sy0">=</span> <span class="br0">&#91;</span>tableView dequeueReusableCellWithIdentifier<span class="sy0">:</span>CellIdentifier<span class="br0">&#93;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span>cell <span class="sy0">==</span> <span class="kw2">nil</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
cell <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><span class="br0">&#91;</span>UITableViewCell alloc<span class="br0">&#93;</span> initWithStyle<span class="sy0">:</span>UITableViewCellStyleDefault reuseIdentifier<span class="sy0">:</span>CellIdentifier<span class="br0">&#93;</span> autorelease<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="co2">// Configure the cell.</span><br />
cell.accessoryType <span class="sy0">=</span> UITableViewCellAccessoryDetailDisclosureButton;<br />
cell.textLabel.text <span class="sy0">=</span> <span class="co3">@</span><span class="st0">&quot;Hello World!!!&quot;</span>;<br />
<span class="kw1">return</span> cell;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>tableView<span class="sy0">:</span><span class="br0">&#40;</span>UITableView <span class="sy0">*</span><span class="br0">&#41;</span>tableView didSelectRowAtIndexPath<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span class="kw5">NSIndexPath</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>indexPath<br />
<span class="br0">&#123;</span></p>
<p>NextViewController <span class="sy0">*</span>nextViewController <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>NextViewController alloc<span class="br0">&#93;</span> initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;NextViewController&quot;</span> bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="co2">// &#8230;</span><br />
<span class="co2">// Pass the selected object to the new view controller.</span><br />
<span class="br0">&#91;</span>self.navigationController pushViewController<span class="sy0">:</span>nextViewController animated<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>nextViewController release<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Relinquish ownership any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.</span><br />
<span class="co2">// For example: self.myOutlet = nil;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 5:</strong> Double click the NextViewController.xib file and open it to the Interface Builder. First select the view window and bring up Attribute Inspector and change the background color. Select Label from the library and place into the view, select the label from view and bring up Attribute Inspector change the Text into &#8220;Hello world!!!&#8221; , and change font size. Now save the .xib file close it and go back to the Xcode.</p>
<p><strong>Step 6:</strong> Compile and run the application in the Simulator.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/08/ToolBar.jpg"><img class="alignnone size-full wp-image-3199" title="ToolBar" src="http://www.edumobile.org/iphone/wp-content/uploads/2011/08/ToolBar.jpg" alt="" width="150" height="150" /></a><br />
You can <strong>Download SourceCode</strong> from here <a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/08/ToolBar.zip">ToolBar</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-interface-builder/toolbar-application-in-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>KeyBoard example in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/keyboard-example-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/keyboard-example-in-iphone/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 07:49:58 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[KeyBoard Example]]></category>
		<category><![CDATA[KeyBoard example in iPhone]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3131</guid>
		<description><![CDATA[This is the simple KeyBoard example. In this example we will see how to keyBoard implement the application and hide from the application using button pressed. So let see how it will worked.]]></description>
			<content:encoded><![CDATA[<p>This is the simple KeyBoard example. In this example we will see how to keyBoard implement the application and hide from the application using button pressed. So let see how it will worked. My last post you can find out from here  <a href="http://www.edumobile.org/iphone/iphone-programming-tutorials/move-image-using-touch-function-in-iphone/">MoveImage</a></p>
<p><strong>Step 1: </strong>Open the Xcode, Create a new project using View Base application. Give the application “KeyBoard_Example”.</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> Open the KeyBoard_ExampleViewController.h file, make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@interface</span> KeyBoard_ExampleViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>IBOutlet UITextField <span class="sy0">*</span>textField;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 4:</strong> Double click the KeyBoard_ExampleViewController.xib file and open it to the Interface Builder. First drag the label and place it to the view window, change the label name into &#8220;Name&#8221; and drag the TextField from the library and place it to the view window. Select the TextField and bring up Attributes Inspector and the placeholder into&#8221;Enter your name&#8221; and select the TextFiled once again and bring up Connection Inspector and connect delegate to the File&#8217;s Owner icon. Now, save the .xib file and go back to the Xcode.</p>
<p><strong>Step 5: </strong>In the KeyBoard_ExampleViewController.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;KeyBoard_ExampleViewController.h&quot;</span><br />
<span class="kw1">@implementation</span> KeyBoard_ExampleViewController</p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>textFieldShouldReturn<span class="sy0">:</span><span class="br0">&#40;</span>UITextField <span class="sy0">*</span><span class="br0">&#41;</span>textField<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>textField resignFirstResponder<span class="br0">&#93;</span>;<br />
<span class="kw1">return</span> <span class="kw2">YES</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span><br />
<span class="co1">#pragma mark &#8211; View lifecycle</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span></p>
<p><span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 6:</strong> Now compile and the run the application on the Simulator.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/07/11.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/07/11-157x300.jpg" alt="" title="1" width="157" height="300" class="alignnone size-medium wp-image-3136" /></a></p>
<p>You can <strong>Download SourceCode</strong> from here   <a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/07/KeyBoard_Example1.zip">KeyBoard_Example</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/keyboard-example-in-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Move Image using Touch Function in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/move-image-using-touch-function-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/move-image-using-touch-function-in-iphone/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 10:20:34 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Interface Builder]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[Move Image]]></category>
		<category><![CDATA[Move Image using Touch Function in iPhone]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3123</guid>
		<description><![CDATA[This is the very simple application. In this application we will see how to image move using touch. So let see how it will work. ]]></description>
			<content:encoded><![CDATA[<p>This is the very simple application. In this application we will see how to image move using touch. So let see how it will work. My previous post you can find out from here <a href="http://www.edumobile.org/iphone/iphone-programming-tutorials/imageview-display-after-pressing-button-in-iphone/">ImageView Display</a></p>
<p><strong>Step 1 : </strong>Open the Xcode, Create a new project using View Base application. Give the application “Touch_Image”.</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>We need add also two resource in the project.</p>
<p><strong>Step 4: </strong>In the Touch_ImageViewController.h file, make the following changes.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@interface</span> Touch_ImageViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span><br />
UIImageView <span class="sy0">*</span>image;<br />
<span class="br0">&#125;</span><br />
<span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet UIImageView <span class="sy0">*</span>image;<br />
<span class="kw1">@end</span></div>
</div>
<p><strong>Step 5:</strong> Double click the Touch_ImageViewController.xib file and open it to the interface builder. First select the view and bring up Attribute Inspector and change the background color. Drag the label from the library and place it to the view window. Select the label and bring up Attributes Inspector and the text to &#8220;Touch Anywhere&#8221; . Now drag the ImageView from the library and place it to the view window. Select the Image View from the view and bring up Attribute Inspector and select the litchi-big.png image. Connect File&#8217;s Owner icon to the image view and select image. Now save the .xib file, save it and go back to the Xcode.</p>
<p><strong>Step 6: </strong>Open the Touch_ImageViewController.m file and make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;Touch_ImageViewController.h&quot;</span></p>
<p><span class="kw1">@implementation</span> Touch_ImageViewController</p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>touchesBegan<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span class="kw5">NSSet</span></a><span class="sy0">*</span><span class="br0">&#41;</span>touches withEvent<span class="sy0">:</span><span class="br0">&#40;</span>UIEvent<span class="sy0">*</span><span class="br0">&#41;</span>event<br />
<span class="br0">&#123;</span></p>
<p>UITouch <span class="sy0">*</span>touch <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>event allTouches<span class="br0">&#93;</span> anyObject<span class="br0">&#93;</span>;<br />
CGPoint touchLocation <span class="sy0">=</span> <span class="br0">&#91;</span>touch locationInView<span class="sy0">:</span>touch.view<span class="br0">&#93;</span>;<br />
image.center <span class="sy0">=</span> touchLocation;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span></p>
<p><span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 7: </strong>Now compile and run the application on the Simulator.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/07/1.jpg"><img class="alignnone size-medium wp-image-3125" title="1" src="http://www.edumobile.org/iphone/wp-content/uploads/2011/07/1-159x300.jpg" alt="" width="159" height="300" /></a></p>
<p>You can <strong>Download SourceCode</strong> from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/07/Touch_Image.zip'>Touch_Image</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/move-image-using-touch-function-in-iphone/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ImageView display after pressing Button in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/imageview-display-after-pressing-button-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/imageview-display-after-pressing-button-in-iphone/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 07:42:46 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Interface Builder]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[ImageView display]]></category>
		<category><![CDATA[ImageView display after pressing Button in iPhone]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3117</guid>
		<description><![CDATA[In this application we will see how to image display after pressing button. So let see how it will worked. ]]></description>
			<content:encoded><![CDATA[<p>In this application we will see how to image display after pressing button. So let see how it will worked. Another Button Pressed example you can find out from here <a href="http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-change-background-color-after-pressing-button-in-iphone/">Change BackgroundColor</a></p>
<p><strong>Step 1:</strong> Open the Xcode, Create a new project using View Base application. Give the application “Button_Fun”.</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> We need to add two UIViewController class in the project. So select the project -&gt; New File -&gt; Cocoa Touch -&gt;ViewController class and give the class name ”ImageView” and “SecondImageView”.</p>
<p><strong>Step 4:</strong> We need add also two resource in the project.</p>
<p><strong>Step 5: </strong>Open the Button_FunViewController.h file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span><br />
<span class="kw1">@interface</span> Button_FunViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>IBOutlet UIButton<span class="sy0">*</span>button;<br />
<span class="br0">&#125;</span><br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>ButtonPressed<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>SecondButtonPressed<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 6:</strong> Double click the Button_FunViewController.xib file and open it to the Interface Builder. First drag the two Round Rect button from the library and place it to the view window and give the name of the buttons &#8220;FirstButton&#8221; and &#8220;SecondButton&#8221;. Select the FirstButton from the view window and bring up Connection Inspector and connect Touch Up Inside to the Files owner icon and select ButtonPressed: method. Select the another button &#8220;SecondButton&#8221; and bring up Connection Inspector and connect Touch Up Inside to the Files owner icon and select SecondButtonPressed: method.Now save the .xib file, close it and go back to the Xcode.</p>
<p><strong>Step 7:</strong> Double click the ImageView.xib file and open it to the Interface Builder. Drag the image view from the library and place it to the view window. Select the ImageView from the view and bring up Attribute Inspector and select the &#8220;cutest-baby-5.jpg&#8221;. Now save the .xib file , close it and go back to the Xcode.</p>
<p><strong>Step 8: </strong>Double click the SeconImageView.xib file and open it to the Interface Builder. Drag the image view from the library and place it to the view window. Select the ImageView from the view and bring up Attribute Inspector and select the &#8220;cutest-baby-6.jpg&#8221;. Now save the .xib file , close it and go back to the Xcode.</p>
<p><strong>Step 9:</strong> In the Button_FunViewController.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;Button_FunViewController.h&quot;</span><br />
<span class="co1">#import &quot;ImageView.h&quot;</span><br />
<span class="co1">#import &quot;SecondImageview.h&quot;</span></p>
<p><span class="kw1">@implementation</span> Button_FunViewController</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>ButtonPressed<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
ImageView <span class="sy0">*</span>imageView <span class="sy0">=</span><span class="br0">&#91;</span><span class="br0">&#91;</span>ImageView alloc<span class="br0">&#93;</span><br />
initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;ImageView&quot;</span><br />
bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>imageView.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>SecondButtonPressed<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
SecondImageview <span class="sy0">*</span>secondImageView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>SecondImageview alloc<span class="br0">&#93;</span><br />
initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;SecondImageview&quot;</span><br />
bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;</p>
<p><span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>secondImageView.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span></p>
<p><span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 10:</strong> Now compile and run the application on the Simulator.<br />
<a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/07/1-39.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/07/1-39-162x300.jpg" alt="" title="1-39" width="162" height="300" class="alignnone size-medium wp-image-3119" /></a></p>
<p>You can <strong>Download SourceCode </strong>from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/07/Button_Fun.zip'>Button_Fun</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/imageview-display-after-pressing-button-in-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Change background color after pressing Button in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-change-background-color-after-pressing-button-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-change-background-color-after-pressing-button-in-iphone/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 07:29:38 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[Change Background Color]]></category>
		<category><![CDATA[How to Change background color after pressing Button in iPhone]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3111</guid>
		<description><![CDATA[In this application we will see how to change background color using button pressed. So let see how it will worked.]]></description>
			<content:encoded><![CDATA[<p>In this application we will see how to change background color using button pressed. So let see how it will worked.  My previous post you can find out from here  <a href="http://www.edumobile.org/iphone/iphone-programming-tutorials/buttonpressed-example-in-iphone-2/">ButtonPressed</a></p>
<p><strong>Step 1:</strong> Open the Xcode, Create a new project using View Base application. Give the application “BackgroundColor”.</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> Open the BackgroungColorViewController.h file and make the following changes in the file</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@interface</span> BackgroungColorViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>IBOutlet UIButton<span class="sy0">*</span>firstButton;<br />
IBOutlet UIButton<span class="sy0">*</span>secondButton;<br />
IBOutlet UIButton<span class="sy0">*</span>thirdButton;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>FirstButtonPressed<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>SecondButtonPressed<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>ThirdButtonPressed<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 4: </strong>Double click the BackgroungColorViewController.xib file and open it to the Interface Builder. First drag the three Round Rect Button and place it to the view window. Select the first button and bring up Connection Inspector and connect Touch Up Inside to the Files Owner icon and select FirstButtonPressed: method. Do the same thing for other two buttons and select SecondButtonPressed: and ThirdButtonPressed: method. Now save the .xib file, close it and go back to the Xcode.</p>
<p><strong>Step 5:</strong> In the BackgroungColorViewController.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;BackgroungColorViewController.h&quot;</span><br />
<span class="kw1">@implementation</span> BackgroungColorViewController</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>FirstButtonPressed<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
self.view.backgroundColor <span class="sy0">=</span> <span class="br0">&#91;</span>UIColor greenColor<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>SecondButtonPressed<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
self.view.backgroundColor <span class="sy0">=</span> <span class="br0">&#91;</span>UIColor yellowColor<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>ThirdButtonPressed<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
self.view.backgroundColor <span class="sy0">=</span> <span class="br0">&#91;</span>UIColor redColor<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="coMULTI">/*<br />
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.<br />
- (void)viewDidLoad<br />
{<br />
[super viewDidLoad];<br />
}<br />
*/</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="co2">// Release any retained subviews of the main view.</span><br />
<span class="co2">// e.g. self.myOutlet = nil;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Return YES for supported orientations</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 6:</strong> Now compile and run the application on the simulator.<br />
<a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/07/1-37.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/07/1-37-156x300.jpg" alt="" title="1-37" width="156" height="300" class="alignnone size-medium wp-image-3113" /></a></p>
<p>You can <strong>Download SourceCode</strong> from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/07/BackgroungColor.zip'>BackgroungColor</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-change-background-color-after-pressing-button-in-iphone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ScrollView Example in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/scrollview-example-in-iphone-2/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/scrollview-example-in-iphone-2/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 07:59:50 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Interface Builder]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[ScrollView]]></category>
		<category><![CDATA[ScrollView example in iPhone]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3078</guid>
		<description><![CDATA[In this application we will see how to TextField implement in the ScrollView. So let see how it will worked.]]></description>
			<content:encoded><![CDATA[<p>In this application we will see how to TextField implement in the ScrollView. So let see how it will worked. Another ScrollView example you can find out from here <a href="http://www.edumobile.org/iphone/iphone-programming-tutorials/scrollview-example-in-iphone/">ScrollView Example</a></p>
<p><strong>Step 1: </strong>Open the Xcode, Create a new project using View Base application. Give the application “ScrollView_Example”.</p>
<p><strong>Step 2:</strong> <strong> </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>Open the ScrollView_ExampleViewController.h file and make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p>
<span class="kw1">@interface</span> ScrollView_ExampleViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>IBOutlet UIScrollView <span class="sy0">*</span>scrollView;</p>
<p>IBOutlet UITextField <span class="sy0">*</span>textfield1;<br />
IBOutlet UITextField <span class="sy0">*</span>textfield2;<br />
IBOutlet UITextField <span class="sy0">*</span>textfield3;<br />
IBOutlet UITextField <span class="sy0">*</span>textfield4;<br />
IBOutlet UITextField <span class="sy0">*</span>textfield5;<br />
IBOutlet UITextField <span class="sy0">*</span>textfield6;<br />
IBOutlet UITextField <span class="sy0">*</span>textfield7;<br />
IBOutlet UITextField <span class="sy0">*</span>textfield8;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 4:</strong> Double click the ScrollView_ExampleViewController.xib file and open it to the Interface Builder. First drag the ScrollView from the library and place it to the view window. Next drag eight Label and eight UITextField from the library and place it to the view window (See the figure 1). Select the ScrollView from the view and bring up Size Inspector and changed the y position (-200) (See figure 2). Now Save the ScrollView_ExampleViewController.xib file , close it and go back to the Xcode.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/1-34.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/1-34-300x206.jpg" alt="" title="1-34" width="300" height="206" class="alignnone size-medium wp-image-3079" /></a><br />
                              <strong>  Figure 1</strong></p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/2-17.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/2-17-300x163.jpg" alt="" title="2-17" width="300" height="163" class="alignnone size-medium wp-image-3080" /></a><br />
                            <strong>Figure 2</strong></p>
<p><strong>Step 5:</strong> In the ScrollView_ExampleViewController.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;ScrollView_ExampleViewController.h&quot;</span></p>
<p><span class="kw1">@implementation</span> ScrollView_ExampleViewController</p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="co2">// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span></p>
<p><span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;</p>
<p>scrollView.frame <span class="sy0">=</span> CGRectMake<span class="br0">&#40;</span>0, 0, 320, 460<span class="br0">&#41;</span>;<br />
<span class="br0">&#91;</span>scrollView setContentSize<span class="sy0">:</span>CGSizeMake<span class="br0">&#40;</span>320, 678<span class="br0">&#41;</span><span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>textFieldShouldReturn<span class="sy0">:</span><span class="br0">&#40;</span>UITextField <span class="sy0">*</span><span class="br0">&#41;</span>textField<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>textField resignFirstResponder<span class="br0">&#93;</span>;<br />
<span class="kw1">return</span> <span class="kw2">YES</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="co2">// Release any retained subviews of the main view.</span><br />
<span class="co2">// e.g. self.myOutlet = nil;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 6:</strong> Now compile and run the application on the Simulator.<br />
<a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/3-13.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/3-13-153x300.jpg" alt="" title="3-13" width="153" height="300" class="alignnone size-medium wp-image-3081" /></a></p>
<p>You can <strong>Download SourceCode</strong> from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/06/ScrollView_Example.zip'>ScrollView_Example</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/scrollview-example-in-iphone-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to implement PickerView Programmatically in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-implement-pickerview-programmatically-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-implement-pickerview-programmatically-in-iphone/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 09:21:44 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Interface Builder]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[How to implement PickerView Programmatically in iPhone]]></category>
		<category><![CDATA[PickerView Programmatically]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3070</guid>
		<description><![CDATA[This is the PickerView example. In this example we will see how to implement PickerView Programmatically in iPhone. So let see how it will worked.
]]></description>
			<content:encoded><![CDATA[<p>This is the PickerView example. In this example we will see how to implement PickerView Programmatically in iPhone. So let see how it will worked.  Another PickerView reference you can find out from here <a href="http://www.edumobile.org/iphone/iphone-programming-tutorials/display-datepicker-singlecomponentpicker-and-doublecomponentpicker-with-each-of-the-tabbar-in-iphone/">DatePicker SingleComponentPicker and DoublecomponentPicker</a></p>
<p><strong>Step 1:</strong> Open the Xcode, Create a new project using View Base application. Give the application “PickerView_Programatically”.</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>: We need to add images in the resource folder.</p>
<p><strong>Step 4: </strong>Open the PickerView_ProgramaticallyViewController.h file and make the following changes in the file.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@interface</span> PickerView_ProgramaticallyViewController <span class="sy0">:</span> UIViewController &lt;UIPickerViewDelegate&gt; <span class="br0">&#123;</span></p>
<p>UIButton <span class="sy0">*</span>pickerButton;<br />
UIPickerView <span class="sy0">*</span>myPickerView;<br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span class="kw5">NSMutableArray</span></a> <span class="sy0">*</span>array_from;<br />
UILabel <span class="sy0">*</span>fromButton;<br />
UIButton <span class="sy0">*</span>doneButton ;<br />
UIButton <span class="sy0">*</span>backButton ;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet UIButton <span class="sy0">*</span>pickerButton;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet UILabel <span class="sy0">*</span>fromButton;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>PickerView<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 5:</strong> Double click the PickerView_ProgramaticallyViewController.xib file an open it to the Interface Builder. First drag the button and label, and place it to the view window. Select the button and bring up Attribute Inspector and give the Title &#8220;PickerView&#8221; and bring up Connection Inspector and connect File&#8217;s Owner icon to the button and select pickerButton. And connect Touch Up Inside to the File&#8217;s Owner icon select PickerView: method. Connect File&#8217;s Owner icon to the label and select fromButton. Now save the .xib file, close it and go back to the Xcode.</p>
<p><strong>Step 6: </strong>In the PickerView_ProgramaticallyViewController.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;PickerView_ProgramaticallyViewController.h&quot;</span></p>
<p><span class="kw1">@implementation</span> PickerView_ProgramaticallyViewController</p>
<p><span class="kw1">@synthesize</span> pickerButton,fromButton;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>PickerView<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
myPickerView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIPickerView alloc<span class="br0">&#93;</span> initWithFrame<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>0, 200, 320, 200<span class="br0">&#41;</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>myPickerView<span class="br0">&#93;</span>;<br />
myPickerView.delegate <span class="sy0">=</span> self;<br />
myPickerView.showsSelectionIndicator <span class="sy0">=</span> <span class="kw2">YES</span>;</p>
<p>doneButton <span class="sy0">=</span> <span class="br0">&#91;</span>UIButton buttonWithType<span class="sy0">:</span>UIButtonTypeRoundedRect<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>doneButton addTarget<span class="sy0">:</span>self<br />
action<span class="sy0">:</span><span class="kw1">@selector</span><span class="br0">&#40;</span>aMethod<span class="sy0">:</span><span class="br0">&#41;</span><br />
forControlEvents<span class="sy0">:</span>UIControlEventTouchDown<span class="br0">&#93;</span>;<br />
doneButton.frame <span class="sy0">=</span> CGRectMake<span class="br0">&#40;</span>265.0,202.0, &nbsp;52.0, 30.0<span class="br0">&#41;</span>;<br />
UIImage <span class="sy0">*</span>img <span class="sy0">=</span> <span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;done.png&quot;</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>doneButton setImage<span class="sy0">:</span>img forState<span class="sy0">:</span>UIControlStateNormal<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#91;</span>img release<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>doneButton<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>aMethod<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>myPickerView removeFromSuperview<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#91;</span>doneButton removeFromSuperview<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="co2">// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;</p>
<p>array_from<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/NSMutableArray_Class/"><span class="kw5">NSMutableArray</span></a> alloc<span class="br0">&#93;</span>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 />
<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>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Return YES for supported orientations</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="co2">// tell the picker how many rows are available for a given component</span><br />
<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 numberOfRowsInComponent<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>component <span class="br0">&#123;</span><br />
NSUInteger numRows <span class="sy0">=</span> <span class="nu0">7</span>;</p>
<p><span class="kw1">return</span> numRows;<br />
<span class="br0">&#125;</span></p>
<p><span class="co2">// tell the picker how many components it will have</span><br />
<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 <span class="br0">&#123;</span><br />
<span class="kw1">return</span> <span class="nu0">1</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</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 didSelectRow<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>row inComponent<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>component<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>fromButton setText<span class="sy0">:</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> stringWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;%@&quot;</span>,<span class="br0">&#91;</span>array_from objectAtIndex<span class="sy0">:</span><span class="br0">&#91;</span>pickerView selectedRowInComponent<span class="sy0">:</span>0<span class="br0">&#93;</span><span class="br0">&#93;</span><span class="br0">&#93;</span><span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><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 titleForRow<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>row forComponent<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>component<br />
<span class="br0">&#123;</span></p>
<p><span class="kw1">return</span> <span class="br0">&#91;</span>array_from objectAtIndex<span class="sy0">:</span>row<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="co2">// tell the picker the width of each row for a given component</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span>CGFloat<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 widthForComponent<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>component <span class="br0">&#123;</span><br />
CGFloat componentWidth <span class="sy0">=</span> <span class="nu0">0.0</span>;<br />
componentWidth <span class="sy0">=</span> <span class="nu0">135.0</span>;</p>
<p><span class="kw1">return</span> componentWidth;<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 7:</strong> Now compile and run the application on the Simulator.<br />
<a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/1-32.jpg"><img class="alignnone size-medium wp-image-3072" title="1-32" src="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/1-32-161x300.jpg" alt="" width="161" height="300" /></a></p>
<p>You can <strong>Download SourceCode</strong> from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/06/PickerView_Programatically1.zip'>PickerView_Programatically</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-implement-pickerview-programmatically-in-iphone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ButtonPressed example in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/buttonpressed-example-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/buttonpressed-example-in-iphone/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 08:10:27 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Interface Builder]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[ButtonPressed example]]></category>
		<category><![CDATA[ButtonPressed example in iPhone]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3062</guid>
		<description><![CDATA[This is the ButtonPressed example. In this example we will see how to load another view after pressing button. So let see how it will worked.]]></description>
			<content:encoded><![CDATA[<p>This is the ButtonPressed example. In this example we will see how to load another view after pressing button. So let see how it will worked.  Another Buttonpress reference you can find out from here <a href="http://www.edumobile.org/iphone/iphone-programming-tutorials/buttonview-in-iphone/">ButtonView in iPhone</a></p>
<p><strong>Step 1: </strong>Open the Xcode, Create a new project using View base application. Give the application “ButtonPress”.</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> Xpand classes and notice Interface Builder created the ButtonPressViewController class for you and generated a separate nib, ButtonPressViewController.xib for the “ButtonPress”.</p>
<p><strong>Step 4:</strong> We need to add three UIViewController in the class in the project. So select the project -&gt; New File -&gt; Cocoa Touch -&gt;ViewController class and give the class name ”FirstView”, “SecondView” and &#8220;ThirdView&#8221;.</p>
<p><strong>Step 5: </strong>We need to add background image in the Resource folder.</p>
<p><strong>Step 6:</strong> Open the ButtonPressViewController.h file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@class</span> ButtonPressViewController;<br />
<span class="kw1">@interface</span> ButtonPressAppDelegate <span class="sy0">:</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span class="kw5">NSObject</span></a> &nbsp;<span class="br0">&#123;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet UIWindow <span class="sy0">*</span>window;<br />
<span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet ButtonPressViewController <span class="sy0">*</span>viewController;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 7: </strong>Double click the ButtonPressViewController.xib file and open it to the Interface Builder. First select view and bring up Attributes Inspector change the background color &#8220;Black&#8221;. Now drag three button from the library and place it to the view window. Select the buttons from view window and bring up Attribute Inspector and change the Title name into &#8220;FirstView&#8221;,&#8221;SecondView&#8221; and &#8220;ThirdView&#8221;. Select the FirstView button from view and bring up Connection Inspector and connect Touch Up Inside to the Files owner icon and select FirstView: method (See the below figure) . Do the same thing for other two buttons and select SecondView: and ThirdView: method. Save the .xib file, close it and go back to the Xcode.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/1-35.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/1-35-300x153.jpg" alt="" title="1-35" width="300" height="153" class="alignnone size-medium wp-image-3090" /></a></p>
<p><strong>Step 8: </strong>In the  ButtonPressViewController.m file make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;ButtonPressViewController.h&quot;</span><br />
<span class="co1">#import &quot;FirstView.h&quot;</span><br />
<span class="co1">#import &quot;SecondView.h&quot;</span><br />
<span class="co1">#import &quot;ThirdView.h&quot;</span></p>
<p><span class="kw1">@implementation</span> ButtonPressViewController</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>FirstView<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
FirstView<span class="sy0">*</span>firstView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>FirstView alloc<span class="br0">&#93;</span><br />
initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;FirstView&quot;</span><br />
bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>firstView.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>SecondView<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
SecondView<span class="sy0">*</span>secondView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>SecondView alloc<span class="br0">&#93;</span><br />
initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;SecondView&quot;</span><br />
bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>secondView.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>ThirdView<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
ThirdView<span class="sy0">*</span>thirdView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>ThirdView alloc<span class="br0">&#93;</span><br />
initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;ThirdView&quot;</span><br />
bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>thirdView.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 9:</strong> Open the FirstView.h file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@interface</span> FirstView <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p><span class="br0">&#125;</span><br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 10: </strong>Double click the FirstView.xib file and open it to the Interface Builder. First select the view and bring up Attribute Inspector and change the background color. Drag the label from the library and place it to the view window and change the Text of the label. Drag the Navigation Bar from the library and place it to the top position of the view window. Now drag the button from the library and place it on the navigation bar. Select the button and bring up Attribute Inspector and select the &#8220;backbutton.png&#8221; and bring up Connection Inspector, connect Touch Up Inside to the File&#8217;s Owner icon and select BackButton: method. Now save the .xib file , close it and go back to Xcode.</p>
<p><strong>Step 11: </strong>In the FirstView.m file make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;FirstView.h&quot;</span></p>
<p><span class="kw1">@implementation</span> FirstView</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>self.view removeFromSuperview<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>initWithNibName<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>nibNameOrNil bundle<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span class="kw5">NSBundle</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>nibBundleOrNil<br />
<span class="br0">&#123;</span><br />
self <span class="sy0">=</span> <span class="br0">&#91;</span>super initWithNibName<span class="sy0">:</span>nibNameOrNil bundle<span class="sy0">:</span>nibBundleOrNil<span class="br0">&#93;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span>self<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co2">// Custom initialization</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">return</span> self;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 12:</strong> Open the SecondView.h file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@interface</span> SecondView <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 13:</strong> Double click the SecondView.xib file and open it to the Interface Builder. First select the view and bring up Attribute Inspector and change the background color. Drag the label from the library and place it to the view window and change the Text of the label. Drag the Navigation Bar from the library and place it to the top position of the view window. Now drag the button from the library and place it on the navigation bar. Select the button and bring up Attribute Inspector and select the &#8220;backbutton.png&#8221; and bring up Connection Inspector, connect Touch Up Inside to the File&#8217;s Owner icon and select BackButton: method. Now save the .xib file , close it and go back to Xcode.</p>
<p><strong>Step 14:</strong> In the SecondView.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;SecondView.h&quot;</span></p>
<p><span class="kw1">@implementation</span> SecondView</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>self.view removeFromSuperview<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>initWithNibName<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>nibNameOrNil bundle<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span class="kw5">NSBundle</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>nibBundleOrNil<br />
<span class="br0">&#123;</span><br />
self <span class="sy0">=</span> <span class="br0">&#91;</span>super initWithNibName<span class="sy0">:</span>nibNameOrNil bundle<span class="sy0">:</span>nibBundleOrNil<span class="br0">&#93;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span>self<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co2">// Custom initialization</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">return</span> self;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="co2">// Do any additional setup after loading the view from its nib.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="co2">// Release any retained subviews of the main view.</span><br />
<span class="co2">// e.g. self.myOutlet = nil;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Return YES for supported orientations</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 15:</strong> Open the ThirdView.h file and make the following changes :</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@interface</span> ThirdView <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p><span class="br0">&#125;</span><br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;<br />
<span class="kw1">@end</span></div>
</div>
<p><strong>Step 16: </strong>Double click the ThirdView.xib file and open it to the Interface Builder. First select the view and bring up Attribute Inspector and change the background color. Drag the label from the library and place it to the view window and change the Text of the label. Drag the Navigation Bar from the library and place it to the top position of the view window. Now drag the button from the library and place it on the navigation bar. Select the button and bring up Attribute Inspector and select the &#8220;backbutton.png&#8221; and bring up Connection Inspector, connect Touch Up Inside to the File&#8217;s Owner icon and select BackButton: method. Now save the .xib file , close it and go back to Xcode.</p>
<p><strong>Step 17: </strong>In the ThirdView.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;ThirdView.h&quot;</span></p>
<p><span class="kw1">@implementation</span> ThirdView</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>self.view removeFromSuperview<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>initWithNibName<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>nibNameOrNil bundle<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span class="kw5">NSBundle</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>nibBundleOrNil<br />
<span class="br0">&#123;</span><br />
self <span class="sy0">=</span> <span class="br0">&#91;</span>super initWithNibName<span class="sy0">:</span>nibNameOrNil bundle<span class="sy0">:</span>nibBundleOrNil<span class="br0">&#93;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span>self<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co2">// Custom initialization</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">return</span> self;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="co2">// Do any additional setup after loading the view from its nib.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="co2">// Release any retained subviews of the main view.</span><br />
<span class="co2">// e.g. self.myOutlet = nil;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Return YES for supported orientations</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 18:</strong> Now compile and run the application on the Simulator.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/1-29.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/1-29-162x300.jpg" alt="" title="1-29" width="162" height="300" class="alignnone size-medium wp-image-3064" /></a></p>
<p>You can <strong>Download SourceCode</strong> from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/06/ButtonPress.zip'>ButtonPress</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/buttonpressed-example-in-iphone/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Splash Screen with TabBar and TableView in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/splash-screen-with-tabbar-and-tableview-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/splash-screen-with-tabbar-and-tableview-in-iphone/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 10:44:09 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Interface Builder]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[Splash Screen with TabBar and TableView in iPhone]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3055</guid>
		<description><![CDATA[This is the TabBar and tableView example . In this example we will see first display the Splash screen later after comes tableview in TabBar controller. So let see how it will work.]]></description>
			<content:encoded><![CDATA[<p>This is the TabBar and tableView example . In this example we will see first display the Splash screen later after comes tableview in TabBar controller. So let see how it will work.</p>
<p><strong>Step 1:</strong> Open the Xcode, Create a new project using Window Base application. Give the application “TabBarWithTableView”.</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> We need to add two UIViewController in the class in the project. So select the project -&gt; New File -&gt; Cocoa Touch -&gt;ViewController class and give the class name ”Tableview” and “SecondView”.</p>
<p><strong>Step 4: </strong>We need to add background image in the Resource folder.</p>
<p><strong>Step 5:</strong> Open the TabBarWithTableViewAppDelegate.h file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@interface</span> TabBarWithTableViewAppDelegate <span class="sy0">:</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span class="kw5">NSObject</span></a> &lt;UIApplicationDelegate&gt; <span class="br0">&#123;</span></p>
<p>&nbsp; &nbsp; UITabBarController <span class="sy0">*</span>tabBarControlller;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span><br />
<span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet UITabBarController <span class="sy0">*</span>tabBarControlller;<br />
<span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet UIWindow <span class="sy0">*</span>window;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 6: </strong>Double click the MainWindow.xib file and open it to the Interface Builder.First drag the “Image View” from the library and place it to the window. Select the window and bring up attribute inspector and select the “logo.png”.Drag the TabBarController from the library in the interface builder. First select the first tab from the TabBarController and bring up Identity Inspector and select “TableView” class. Do the same thing for the Second Tab and select “SecondView”. Now save it, close it and go back to the Xcode.</p>
<p><strong>Step 7:</strong> In the TabBarWithTableViewAppDelegate.m file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;TabBarWithTableViewAppDelegate.h&quot;</span></p>
<p><span class="kw1">@implementation</span> TabBarWithTableViewAppDelegate</p>
<p><span class="kw1">@synthesize</span> window<span class="sy0">=</span>_window,tabBarControlller;</p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>application<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application didFinishLaunchingWithOptions<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span class="kw5">NSDictionary</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>launchOptions<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co2">// Override point for customization after application launch.</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>_window addSubview<span class="sy0">:</span>tabBarControlller.view<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>self.window makeKeyAndVisible<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">YES</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationWillResignActive<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationDidEnterBackground<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationWillEnterForeground<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationDidBecomeActive<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationWillTerminate<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>_window release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 8:</strong> Open the TableView.h file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p>
<span class="kw1">@interface</span> TableView <span class="sy0">:</span> UIViewController &lt;UITableViewDelegate,UITableViewDataSource&gt; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &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>listData;<br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><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>listData;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 9: </strong>Double click the TableView.xib file open it to the Interface Builder. First drag the Navigation bar from the library and place it to the view. Select the navigation bar from view and bring up Attribute Inspector and change the Title of the Navigation Bar &#8220;TableView&#8221;. Now drag the TableView from the library and place it to the view . Select the TableView from the view window and bring up Connection Inspector and connect dataSource to the File&#8217;s Owner icon and delegate to the File&#8217;s Owner icon. Save the .xib file, close it and go back to the Xcode.</p>
<p><strong>Step 10:</strong> In the  TableView.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;TableView.h&quot;</span></p>
<p><span class="kw1">@implementation</span> TableView<br />
<span class="kw1">@synthesize</span> listData;</p>
<p><span class="co2">// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.</span><br />
<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; &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> initWithObjects<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;Sleepy&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Sneezy&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Bashful&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Happy&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Doc&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Grumpy&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co3">@</span><span class="st0">&quot;Dopey&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Thorin&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Dorin&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Nori&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Ori&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Balin&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Dwalin&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co3">@</span><span class="st0">&quot;Fili&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Kili&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Oin&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Gloin&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Bifur&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Bofur&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Bombur&quot;</span>,<span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; self.listData <span class="sy0">=</span> array;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>array release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p>
<span class="co2">// Override to allow orientations other than the default portrait orientation.</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co2">// Return YES for supported orientations</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p>
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>listData release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>tableView<span class="sy0">:</span><span class="br0">&#40;</span>UITableView <span class="sy0">*</span><span class="br0">&#41;</span>tableView<br />
numberOfRowsInSection<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>section<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="br0">&#91;</span>self.listData count<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>UITableViewCell <span class="sy0">*</span><span class="br0">&#41;</span>tableView<span class="sy0">:</span><span class="br0">&#40;</span>UITableView <span class="sy0">*</span><span class="br0">&#41;</span>tableView<br />
&nbsp; &nbsp; &nbsp; &nbsp; cellForRowAtIndexPath<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span class="kw5">NSIndexPath</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>indexPath<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw4">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>SimpleTableIdentifier <span class="sy0">=</span> <span class="co3">@</span><span class="st0">&quot;SimpleTableIdentifier&quot;</span>;<br />
&nbsp; &nbsp; UITableViewCell <span class="sy0">*</span>cell <span class="sy0">=</span> <span class="br0">&#91;</span>tableView dequeueReusableCellWithIdentifier<span class="sy0">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SimpleTableIdentifier<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>cell <span class="sy0">==</span> <span class="kw2">nil</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cell <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><span class="br0">&#91;</span>UITableViewCell alloc<span class="br0">&#93;</span> initWithFrame<span class="sy0">:</span>CGRectZero<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reuseIdentifier<span class="sy0">:</span> SimpleTableIdentifier<span class="br0">&#93;</span> autorelease<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NSUInteger row <span class="sy0">=</span> <span class="br0">&#91;</span>indexPath row<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cell.textLabel.text <span class="sy0">=</span> <span class="br0">&#91;</span>listData objectAtIndex<span class="sy0">:</span>row<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> cell;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 11:</strong> Double click the SecondView.xib file and open it to the Interface Builder. Select the view and bring up Attribute Inspector and change the background color. Save the .xib file, close it and go back to the Xcode.</p>
<p><strong>Step 12:</strong> Now compile and run the application on the simulator.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/11.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/11-161x300.jpg" alt="" title="1" width="161" height="300" class="alignnone size-medium wp-image-3058" /></a></p>
<p>You can <strong>Download SourceCode</strong> from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/06/TabBarWithTableView.zip'>TabBarWithTableView</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/splash-screen-with-tabbar-and-tableview-in-iphone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Two Splash Screen display in iphone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/two-splash-screen-display-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/two-splash-screen-display-in-iphone/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 10:37:20 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[Two Splash Screen display in iphone]]></category>
		<category><![CDATA[Two SplashScreen Display]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3048</guid>
		<description><![CDATA[In this application we will see how to applied two splash screen in the iPhone. So let see how it will work.]]></description>
			<content:encoded><![CDATA[<p>In this application we will see how to applied two splash screen in the iPhone. So let see how it will work.</p>
<p><strong>Step 1:</strong> Open the Xcode, Create a new project using Window Base application. Give the application “TwoSplashScreen”.</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> We need to add three UIViewController in the class in the project. So select the project -&gt; New File -&gt; Cocoa Touch -&gt;ViewController class and give the class name “SplashScreen”,”FirstView” and “SecondView”.</p>
<p><strong>Step 4</strong>: We need to add two image in the Resource folder.</p>
<p><strong>Step 5: </strong>Open the TwoSplashScreenAppDelegate.h file and make the following changes in the file.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span><br />
<span class="kw1">@class</span> SplashScreen;</p>
<p><span class="kw1">@interface</span> TwoSplashScreenAppDelegate <span class="sy0">:</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span class="kw5">NSObject</span></a> &lt;UIApplicationDelegate&gt; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;SplashScreen <span class="sy0">*</span>splashScreen;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet UIWindow <span class="sy0">*</span>window;<br />
&nbsp;<span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet SplashScreen <span class="sy0">*</span>splashScreen;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 6:</strong> Double click the MainWindow.xib file open it to the Interface Builder. First drag the &#8220;Image View&#8221; from the library and place it to the window. Select the window and bring up attribute inspector and select the &#8220;logo.png&#8221;. Now save it, close it and go back to the Xcode.</p>
<p><strong>Step 7: </strong>In the TwoSplashScreenAppDelegate.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;TwoSplashScreenAppDelegate.h&quot;</span><br />
<span class="co1">#import &quot;SplashScreen.h&quot;</span></p>
<p><span class="kw1">@implementation</span> TwoSplashScreenAppDelegate</p>
<p>
<span class="kw1">@synthesize</span> window<span class="sy0">=</span>_window,splashScreen;</p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>application<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application didFinishLaunchingWithOptions<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span class="kw5">NSDictionary</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>launchOptions<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; splashScreen <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>SplashScreen alloc<span class="br0">&#93;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;SplashScreen&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>_window addSubview<span class="sy0">:</span>splashScreen.view<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#91;</span>splashScreen displayScreen<span class="br0">&#93;</span>;</p>
<p>&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#91;</span>self.window makeKeyAndVisible<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">YES</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationWillResignActive<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationDidEnterBackground<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationWillEnterForeground<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationDidBecomeActive<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationWillTerminate<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>_window release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 8:</strong> Open the SplashScreen.h file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p>
<span class="kw1">@interface</span> SplashScreen <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; IBOutlet UIImageView <span class="sy0">*</span>displaySplash;<br />
&nbsp; &nbsp; UITabBarController <span class="sy0">*</span>tabBarControlller;</p>
<p><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> IBOutlet UITabBarController <span class="sy0">*</span>tabBarControlller;</p>
<p>&nbsp;<span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet IBOutlet UIImageView <span class="sy0">*</span>displaySplash;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>displayScreen;<br />
<span class="sy0">-</span><span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>removeScreen;</p>
<p>
<span class="kw1">@end</span></div>
</div>
<p><strong>Step 9</strong>: Double click the SplashScreen.xib file and open it to the Interface Builder. First drag the &#8220;Image View&#8221; from the library and place it to the window. Select the window and bring up attribute inspector and select the &#8220;screen.png&#8221;.Connect File&#8217;s Owner icon to the Image View and select displaySplash. Drag the TabBarController from the library in the interface builder. First select the first tab from the TabBarController and bring up Identity Inspector and select &#8220;FirstView&#8221; class. Do the same thing for the Second Tab and select &#8220;SecondView&#8221;.Now save it, close it and go back to the Xcode.</p>
<p><strong>Step 10: </strong>In the SplashScreen.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;SplashScreen.h&quot;</span></p>
<p>
<span class="kw1">@implementation</span> SplashScreen<br />
<span class="kw1">@synthesize</span> displaySplash,tabBarControlller;</p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>initWithNibName<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>nibNameOrNil bundle<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span class="kw5">NSBundle</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>nibBundleOrNil<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; self <span class="sy0">=</span> <span class="br0">&#91;</span>super initWithNibName<span class="sy0">:</span>nibNameOrNil bundle<span class="sy0">:</span>nibBundleOrNil<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>self<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// Custom initialization</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> self;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p>
<span class="sy0">-</span><span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>displayScreen<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSThread_Class/"><span class="kw5">NSThread</span></a> sleepForTimeInterval<span class="sy0">:</span>0.02<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>self performSelector<span class="sy0">:</span><span class="kw1">@selector</span><span class="br0">&#40;</span>removeScreen<span class="br0">&#41;</span> withObject<span class="sy0">:</span><span class="kw2">nil</span> afterDelay<span class="sy0">:</span>16.0<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>removeScreen<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>tabBarControlller.view<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p>
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="co2">// Do any additional setup after loading the view from its nib.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="co2">// Release any retained subviews of the main view.</span><br />
&nbsp; &nbsp; <span class="co2">// e.g. self.myOutlet = nil;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co2">// Return YES for supported orientations</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 11: </strong>Now double click the FirstView.xib file and open it to the Interface Builder. Select the View and bring up Attribute Inspector and change the background color. Now save the it , close it and go back to the Xcode.</p>
<p><strong>Step 12:</strong> Double click the SecondView.xib file and open it to the Interface Builder. Select the View and bring up Attribute Inspector and change the background color. Now save the it , close it and go back to the Xcode.</p>
<p><strong>Step 13:</strong> Now compile and run the application in the Simulator.<br />
<a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/1-26.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/1-26-166x300.jpg" alt="" title="1-26" width="166" height="300" class="alignnone size-medium wp-image-3051" /></a></p>
<p>You can <strong>Download Source Code</strong> from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/06/TwoSplashScreen.zip'>TwoSplashScreen</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/two-splash-screen-display-in-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implement UIButton, UITextField and UILabel programmatically in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/implement-uibutton-uitextfield-and-uilabel-programmatically-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/implement-uibutton-uitextfield-and-uilabel-programmatically-in-iphone/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 08:53:44 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[Implement UIButton]]></category>
		<category><![CDATA[UITextField and UILabel programmatically in iPhone]]></category>
		<category><![CDATA[With out Interface Builder create application]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3038</guid>
		<description><![CDATA[This is the very simple application. In this application we will see how to implement TextField, Label and button programmatically in iPhone. So let see how it will work.]]></description>
			<content:encoded><![CDATA[<p>This is the very simple application. In this application we will see how to implement TextField, Label and button programmatically in iPhone. So let see how it will work.</p>
<p><strong>Step 1:</strong> Open the Xcode, Create a new project using View Base application. Give the application “Example”.</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> We need to add one resource in resource folder. Give the resource name &#8220;anim.png&#8221;.</p>
<p><strong>Step 4: </strong>Open the ExampleViewController.h file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span><br />
<span class="kw1">@interface</span> ExampleViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>UITextField <span class="sy0">*</span>textFieldRounded;<br />
UILabel <span class="sy0">*</span>label;<br />
UIImageView <span class="sy0">*</span>image;<br />
UISlider <span class="sy0">*</span>slider;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> UITextField <span class="sy0">*</span>textFieldRounded;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> UILabel <span class="sy0">*</span>label;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> UIImageView <span class="sy0">*</span>image;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> UISlider <span class="sy0">*</span>slider;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 5:</strong> In the Example.m file make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;ExampleViewController.h&quot;</span></p>
<p><span class="kw1">@implementation</span> ExampleViewController</p>
<p><span class="kw1">@synthesize</span> textFieldRounded,label,image,slider;</p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>textFieldRounded release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>label release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>image release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>slider release<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p>
<span class="co2">// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp;textFieldRounded <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UITextField alloc<span class="br0">&#93;</span> initWithFrame<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>20, 50, 280, 31<span class="br0">&#41;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; textFieldRounded.borderStyle <span class="sy0">=</span> UITextBorderStyleRoundedRect;<br />
&nbsp; &nbsp; textFieldRounded.textColor <span class="sy0">=</span> <span class="br0">&#91;</span>UIColor blackColor<span class="br0">&#93;</span>; <br />
&nbsp; &nbsp; textFieldRounded.font <span class="sy0">=</span> <span class="br0">&#91;</span>UIFont systemFontOfSize<span class="sy0">:</span>17.0<span class="br0">&#93;</span>; <br />
&nbsp; &nbsp; textFieldRounded.placeholder <span class="sy0">=</span> <span class="co3">@</span><span class="st0">&quot;Enter Your name&quot;</span>; &nbsp;<span class="co2">//place holder</span><br />
&nbsp; &nbsp; textFieldRounded.backgroundColor <span class="sy0">=</span> <span class="br0">&#91;</span>UIColor whiteColor<span class="br0">&#93;</span>; <br />
&nbsp; &nbsp; textFieldRounded.autocorrectionType <span class="sy0">=</span> UITextAutocorrectionTypeNo; &nbsp; <br />
&nbsp; &nbsp; &nbsp;textFieldRounded.backgroundColor <span class="sy0">=</span> <span class="br0">&#91;</span>UIColor clearColor<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; textFieldRounded.keyboardType <span class="sy0">=</span> UIKeyboardTypeDefault; &nbsp;<br />
&nbsp; &nbsp; textFieldRounded.returnKeyType <span class="sy0">=</span> UIReturnKeyDone; &nbsp;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; textFieldRounded.clearButtonMode <span class="sy0">=</span> UITextFieldViewModeWhileEditing;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>textFieldRounded<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; textFieldRounded.delegate <span class="sy0">=</span> self;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; UIButton <span class="sy0">*</span>button <span class="sy0">=</span> <span class="br0">&#91;</span>UIButton buttonWithType<span class="sy0">:</span>UIButtonTypeRoundedRect<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>button addTarget<span class="sy0">:</span>self <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;action<span class="sy0">:</span><span class="kw1">@selector</span><span class="br0">&#40;</span>buttonPressed<span class="sy0">:</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp;forControlEvents<span class="sy0">:</span>UIControlEventTouchDown<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>button setTitle<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;Button&quot;</span> forState<span class="sy0">:</span>UIControlStateNormal<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; button.frame <span class="sy0">=</span> CGRectMake<span class="br0">&#40;</span>20, 108, 97, 37<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>button<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; label <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UILabel alloc<span class="br0">&#93;</span> initWithFrame<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>40, 243, 240, 21<span class="br0">&#41;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; label.backgroundColor <span class="sy0">=</span> <span class="br0">&#91;</span>UIColor clearColor<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; label.textAlignment <span class="sy0">=</span> UITextAlignmentCenter; <span class="co2">// UITextAlignmentCenter, UITextAlignmentLeft</span></p>
<p>&nbsp; &nbsp; label.text <span class="sy0">=</span> <span class="co3">@</span><span class="st0">&quot;Label&quot;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>label<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp; CGRect myImageRect <span class="sy0">=</span> CGRectMake<span class="br0">&#40;</span>40.0f, 190.0f, 240.0f, 128.0f<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; image <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIImageView alloc<span class="br0">&#93;</span> initWithFrame<span class="sy0">:</span>myImageRect<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>image setImage<span class="sy0">:</span><span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;anim.png&quot;</span><span class="br0">&#93;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;image.backgroundColor <span class="sy0">=</span> <span class="br0">&#91;</span>UIColor clearColor<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; image.opaque <span class="sy0">=</span> <span class="kw2">YES</span>;<br />
&nbsp; &nbsp; image.alpha <span class="sy0">=</span> <span class="nu0">0</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>image<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>image release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CGRect frame <span class="sy0">=</span> CGRectMake<span class="br0">&#40;</span>18.0, 348.0, 284.0, 23.0<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; slider <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UISlider alloc<span class="br0">&#93;</span> initWithFrame<span class="sy0">:</span>frame<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>slider addTarget<span class="sy0">:</span>self action<span class="sy0">:</span><span class="kw1">@selector</span><span class="br0">&#40;</span>sliderAction<span class="sy0">:</span><span class="br0">&#41;</span> forControlEvents<span class="sy0">:</span>UIControlEventValueChanged<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>slider setBackgroundColor<span class="sy0">:</span><span class="br0">&#91;</span>UIColor clearColor<span class="br0">&#93;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; slider.continuous <span class="sy0">=</span> <span class="kw2">YES</span>;<br />
&nbsp; &nbsp; slider.value <span class="sy0">=</span> <span class="nu0">0.0</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>slider<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span> sliderAction<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span> sender<span class="br0">&#123;</span><br />
&nbsp; &nbsp; image.alpha <span class="sy0">=</span> slider.value;<br />
<span class="br0">&#125;</span></p>
<p>
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span> buttonPressed<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span> sender<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>textFieldRounded resignFirstResponder<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; label.text <span class="sy0">=</span> textFieldRounded.text;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>textFieldShouldReturn<span class="sy0">:</span><span class="br0">&#40;</span>UITextField <span class="sy0">*</span><span class="br0">&#41;</span>textField<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>textField resignFirstResponder<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">YES</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="co2">// Release any retained subviews of the main view.</span><br />
&nbsp; &nbsp; <span class="co2">// e.g. self.myOutlet = nil;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co2">// Return YES for supported orientations</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 6:</strong> Now compile and run the application on the simulator.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/1.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/06/1-169x300.jpg" alt="" title="1" width="169" height="300" class="alignnone size-medium wp-image-3040" /></a></p>
<p>You can <strong>Download SourceCode</strong> from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/06/Example.zip'>Example</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/implement-uibutton-uitextfield-and-uilabel-programmatically-in-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ButtonView in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/buttonview-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/buttonview-in-iphone/#comments</comments>
		<pubDate>Mon, 30 May 2011 12:50:04 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Interface Builder]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[After select the button enter newview]]></category>
		<category><![CDATA[ButtonView in iPhone]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3023</guid>
		<description><![CDATA[This is the ButtonView example. In this example we will see how to mewView will come after pressing button. So let see how it will work.]]></description>
			<content:encoded><![CDATA[<p>This is the ButtonView example. In this example we will see how to mewView will come after pressing button. So let see how it will work.</p>
<p><strong>Step 1:</strong> Open the Xcode, Create a new project using View Base application. Give the application “ButtonView”.</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> We need to add three ViewController class in the project. So select the project -&gt; New File -&gt; Cocoa Touch -&gt;ViewController class and give the class name “PickerView”,”SoundView” and “ImageView”.</p>
<p><strong>Step 4:</strong> We need to add images in the resource folder.</p>
<p><strong>Step 5:</strong> Open the ButtonViewViewController.h file , make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@class</span> PickerView;<br />
<span class="kw1">@class</span> SoundView;<br />
<span class="kw1">@class</span> ImageView;</p>
<p><span class="kw1">@interface</span> ButtonViewViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>PickerView <span class="sy0">*</span>pickerView;<br />
SoundView <span class="sy0">*</span>soundView;<br />
ImageView <span class="sy0">*</span>imageView;</p>
<p>UIButton <span class="sy0">*</span>pickerbutton;<br />
UIButton <span class="sy0">*</span>songbutton;<br />
UIButton <span class="sy0">*</span>imagebutton;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet &nbsp;PickerView <span class="sy0">*</span>pickerView;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet &nbsp;SoundView <span class="sy0">*</span>soundView;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet &nbsp;ImageView <span class="sy0">*</span>imageView;</p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet &nbsp;UIButton <span class="sy0">*</span>pickerbutton;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet &nbsp;UIButton <span class="sy0">*</span>songbutton;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet &nbsp;UIButton <span class="sy0">*</span>imagebutton;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>FirstButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>SecondButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>ThirdButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 6:</strong> Double click the ButtonViewViewController.xib file and open it to the Interface Builder. First drag three Round Rect Button and place it to the view window.Give the button name PickerView, SoundView and ImageView (See the figure 1). Select PickerView button from the View and bring up Connection Inspector now connect Touch Up Inside to the File&#8217;s Owner icon and select FirstButton: method, do the same thing for other two button and select SecondButton: and ThirdButton: method. Now save the .xib file, close it and go back to the Xcode.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/13.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/13-300x235.jpg" alt="" title="1" width="300" height="235" class="alignnone size-medium wp-image-3025" /></a></p>
<p><strong>Figure 1</strong></p>
<p><strong>Step 7:</strong> In the ButtonViewViewController.m file make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;ButtonViewViewController.h&quot;</span><br />
<span class="co1">#import &quot;PickerView.h&quot;</span><br />
<span class="co1">#import &quot;SoundView.h&quot;</span><br />
<span class="co1">#import &quot;ImageView.h&quot;</span></p>
<p><span class="kw1">@implementation</span> ButtonViewViewController<br />
<span class="kw1">@synthesize</span> pickerbutton,songbutton,imagebutton,pickerView,soundView,imageView;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>FirstButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
pickerView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>PickerView alloc<span class="br0">&#93;</span>initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;PickerView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>pickerView.view<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span><br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>SecondButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
soundView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>SoundView alloc<span class="br0">&#93;</span>initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;SoundView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>soundView.view<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span><br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>ThirdButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
imageView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>ImageView alloc<span class="br0">&#93;</span>initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;ImageView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>imageView.view<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>pickerView.view release<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>soundView.view release<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>imageView.view release<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Return YES for supported orientations</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 8:</strong> Open the PickerView.h file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span><br />
<span class="kw1">@interface</span> PickerView <span class="sy0">:</span> UIViewController<br />
<span class="br0">&#123;</span><br />
IBOutlet UIPickerView <span class="sy0">*</span>singlePicker;<br />
<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></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic , retain<span class="br0">&#41;</span> UIPickerView <span class="sy0">*</span>singlePicker;<br />
<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><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>buttonPressed;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 9:</strong> Double click the PickerView.xib file and open it to the Interface Builder. First drag the Picker View, Navigation Bar and Round rect button from the library and place it to the view window (See figure 2). Select the Picker View from the view window and bring up Connection Inspector connect dataSource and delegate to the File&#8217;s Owner icon. Connect File&#8217;s Owner icon to the Picker view and select singlePicker. Drag the Round Rect button place it on the Navigation Bar. Select the button and bring up Attribute Inspector and select &#8220;backbutton.png&#8221;.  Now select the back button and bring up Connection  Inspector connect Touch Up Inspector to the File&#8217;s Owner icon select BackButton: method. Now save the .xib file, close it and go back to the Xcode.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/2.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/2-300x201.jpg" alt="" title="2" width="300" height="201" class="alignnone size-medium wp-image-3026" /></a></p>
<p><strong>Figure 2</strong></p>
<p><strong>Step 10:</strong> In the PickerView.m file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;PickerView.h&quot;</span></p>
<p><span class="kw1">@implementation</span> PickerView</p>
<p><span class="kw1">@synthesize</span> singlePicker;<br />
<span class="kw1">@synthesize</span> pickerData;</p>
<p><span class="co2">// The designated initializer. Override to perform setup that is required before the view is loaded.</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>initWithNibName<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>nibNameOrNil bundle<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span class="kw5">NSBundle</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>nibBundleOrNil <span class="br0">&#123;</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span>self <span class="sy0">=</span> <span class="br0">&#91;</span>super initWithNibName<span class="sy0">:</span>nibNameOrNil bundle<span class="sy0">:</span>nibBundleOrNil<span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co2">// Custom initialization</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">return</span> self;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sende<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>self.view removeFromSuperview<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>buttonPressed<br />
<span class="br0">&#123;</span><br />
NSInteger row <span class="sy0">=</span> <span class="br0">&#91;</span>singlePicker selectedRowInComponent<span class="sy0">:</span>0<span class="br0">&#93;</span>;<br />
<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 />
<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 />
<span class="co3">@</span><span class="st0">&quot;you selected %@!&quot;</span>, selected<span class="br0">&#93;</span>;<br />
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 />
message <span class="sy0">:</span> <span class="co3">@</span><span class="st0">&quot;Thank you for choosing.&quot;</span><br />
delegate<span class="sy0">:</span><span class="kw2">nil</span><br />
cancelButtonTitle <span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;You are Welcome&quot;</span><br />
otherButtonTitles <span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>alert show<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>alert release<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>title release<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="co2">// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.</span><br />
<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 />
<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> initWithObjects<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;Luke&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Leia&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Han&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Chewbacca&quot;</span>,<span class="co3">@</span><span class="st0">&quot;Artoo&quot;</span>,<br />
<span class="co3">@</span><span class="st0">&quot;Threepio&quot;</span>,<span class="co3">@</span><span class="st0">&quot;lando&quot;</span>,<span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
self.pickerData <span class="sy0">=</span> array;<br />
<span class="br0">&#91;</span>array release<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="co2">// Override to allow orientations other than the default portrait orientation.</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation <span class="br0">&#123;</span><br />
<span class="co2">// Return YES for supported orientations</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning <span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload <span class="br0">&#123;</span><br />
<span class="co2">// Release any retained subviews of the main view.</span><br />
<span class="co2">// e.g. self.myOutlet = nil;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc <span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>singlePicker release<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>pickerData release<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark Picker data source methods</span><br />
<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 />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> <span class="nu0">1</span>;<br />
<span class="br0">&#125;</span></p>
<p><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 />
numberOfRowsInComponent<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>component<br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> <span class="br0">&#91;</span>pickerData count<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark Picker delegate method</span><br />
<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 />
titleForRow<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>row<br />
forComponent<span class="sy0">:</span><span class="br0">&#40;</span>NSInteger<span class="br0">&#41;</span>component<br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span><span class="br0">&#91;</span>pickerData objectAtIndex<span class="sy0">:</span>row<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw1">@end</span></div>
</div>
<p><strong>Step 11: </strong>Open the SoundView.h file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span><br />
<span class="kw1">@interface</span> SoundView <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>IBOutlet UIButton <span class="sy0">*</span>Soundstart;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span>IBOutlet UIButton <span class="sy0">*</span>Soundstart;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span> soundplay<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span> sender;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span> soundstop<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span> sender;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span> BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span> sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 12:</strong> Double click the SoundViewxib file and open it to the Interface Builder. Drag two Round Rect Button and Navigation Bar on the view window. Give the Round Rect button name &#8220;Play Sound&#8221; and &#8220;Stop Sound&#8221; . Now select &#8220;Play Sound&#8221; button and bring up Connection Inspector, connect touch Up Inside to the File&#8217;s Owner icon and select soundplay: method, do the same thing for another button and select soundstop: method. Drag the Round Rect Button and place it on the Navigation Bar. Select the Round Rect Button and select &#8220;backbutton.png&#8221;(See figure 3). Now select the back button and bring up Connection Inspector and connect Touch Up Inside to the File&#8217;s Owner icon and select  BackButton: method. Now save the .xib file, close it and go back to the Xcode.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/3.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/3-300x202.jpg" alt="" title="3" width="300" height="202" class="alignnone size-medium wp-image-3027" /></a></p>
<p><strong>Figure 3</strong></p>
<p><strong>Step 13:</strong> We need to add two framework in the FrameWork folder. So add &#8220;AudioToolbox.framework&#8221; and &#8220;AVFoundation.framework&#8221;.</p>
<p><strong>Step 14:</strong> In the SoundView.m file make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;SoundView.h&quot;</span><br />
<span class="co1">#import &lt;AVFoundation/AVFoundation.h&gt;</span></p>
<p><span class="kw1">@implementation</span> SoundView</p>
<p><span class="kw1">@synthesize</span> Soundstart;<br />
AVAudioPlayer <span class="sy0">*</span>player;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>soundplay<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span></p>
<p><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a><span class="sy0">*</span> resourcePath <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/NSBundle_Class/"><span class="kw5">NSBundle</span></a> mainBundle<span class="br0">&#93;</span> resourcePath<span class="br0">&#93;</span>;<br />
resourcePath <span class="sy0">=</span> <span class="br0">&#91;</span>resourcePath stringByAppendingString<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;/sound.wav&quot;</span><span class="br0">&#93;</span>;<br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSError_Class/"><span class="kw5">NSError</span></a><span class="sy0">*</span> err;</p>
<p><span class="co2">//Initialize our player pointing to the path to our resource</span><br />
player <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>AVAudioPlayer alloc<span class="br0">&#93;</span> initWithContentsOfURL<span class="sy0">:</span><br />
<span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span class="kw5">NSURL</span></a> fileURLWithPath<span class="sy0">:</span>resourcePath<span class="br0">&#93;</span> error<span class="sy0">:&amp;</span>amp;err<span class="br0">&#93;</span>;</p>
<p><span class="kw1">if</span><span class="br0">&#40;</span> err <span class="br0">&#41;</span><span class="br0">&#123;</span><br />
<span class="co2">//bail!</span><br />
NSLog<span class="br0">&#40;</span><span class="co3">@</span><span class="st0">&quot;Failed with reason: %@&quot;</span>, <span class="br0">&#91;</span>err localizedDescription<span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw1">else</span><span class="br0">&#123;</span><br />
<span class="co2">//set our delegate and begin playback</span><br />
player.delegate <span class="sy0">=</span> self;<br />
<span class="br0">&#91;</span>player play<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>soundstop<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span>player <span class="sy0">!=</span> <span class="kw2">nil</span> <span class="sy0">&amp;</span>amp;<span class="sy0">&amp;</span>amp; <span class="br0">&#91;</span>player isPlaying<span class="br0">&#93;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>player stop<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span> BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span> sender<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>self.view removeFromSuperview<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>initWithNibName<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>nibNameOrNil bundle<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span class="kw5">NSBundle</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>nibBundleOrNil<br />
<span class="br0">&#123;</span><br />
self <span class="sy0">=</span> <span class="br0">&#91;</span>super initWithNibName<span class="sy0">:</span>nibNameOrNil bundle<span class="sy0">:</span>nibBundleOrNil<span class="br0">&#93;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span>self<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co2">// Custom initialization</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">return</span> self;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="co2">// Do any additional setup after loading the view from its nib.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="co2">// Release any retained subviews of the main view.</span><br />
<span class="co2">// e.g. self.myOutlet = nil;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Return YES for supported orientations</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 15: </strong>Open the ImageView.h file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span><br />
<span class="kw1">@interface</span> ImageView <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span><br />
UIImageView <span class="sy0">*</span>image;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet &nbsp;UIImageView <span class="sy0">*</span>image;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;<br />
<span class="kw1">@end</span></div>
</div>
<p><strong>Step 16: </strong>Double click the ImageView.xib file and open it the Interface Builder. First drag the navigation bar and image view from the library and place it to the view window. And drag the Round rect Button and place it on the Navigation bar. Select the Button and bring up Attributes Inspector and select &#8220;backbutton.png&#8221;. Select the Image view and bring up Attribute Inspector select the &#8220;image006.png&#8221; file (See figure 4). Now save the .xib file, close it and go back to the Xcode.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/4.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/4-300x201.jpg" alt="" title="4" width="300" height="201" class="alignnone size-medium wp-image-3028" /></a></p>
<p><strong>Figure 4</strong></p>
<p><strong>Step 17: </strong>Now compile and run the application on the Simulator.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/5.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/5-168x300.jpg" alt="" title="5" width="168" height="300" class="alignnone size-medium wp-image-3029" /></a></p>
<p>You can <strong>Download SourceCode</strong> from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/05/ButtonView2.zip'>ButtonView</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/buttonview-in-iphone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>GridView using Interface Builder in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/gridview-using-interface-builder-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/gridview-using-interface-builder-in-iphone/#comments</comments>
		<pubDate>Fri, 27 May 2011 12:07:08 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Interface Builder]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[GridView in iPhone]]></category>
		<category><![CDATA[GridView using Interface Builder in iPhone]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=3008</guid>
		<description><![CDATA[In this example we will see how to GridView implement in the application using Interface Builder. This is the very simple example . So let see how it will worked.
]]></description>
			<content:encoded><![CDATA[<p>In this example we will see how to GridView implement in the application using Interface Builder. This is the very simple example . So let see how it will worked.</p>
<p><strong>Step 1:</strong> Open the Xcode, Create a new project using TabBar application. Give the application “GridView”.</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> We need to add five ViewController class in the project. So select the project -&gt; New File -&gt; Cocoa Touch -&gt;ViewController class and give the class name “DetailView”,&#8221;LitchiView&#8221;,&#8221;AppleView&#8221;,&#8221;OrangeView&#8221; and &#8220;StarfruitsView&#8221;.</p>
<p><strong>Step 4:</strong> We need to add images in the resource folder.</p>
<p><strong>Step 5:</strong> Open the FirstViewController.h file and define DetailView,LitchiView,AppleView,OrangeView and StarfruitsView class and create an instance of this class. Create an instance of UIButton class and define IBAction: method. So make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@class</span> DetailView;<br />
<span class="kw1">@class</span> LitchiView;<br />
<span class="kw1">@class</span> AppleView;<br />
<span class="kw1">@class</span> OrangeView;<br />
<span class="kw1">@class</span> StarfruitsView;</p>
<p><span class="kw1">@interface</span> FirstViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>DetailView <span class="sy0">*</span>detailView;<br />
LitchiView <span class="sy0">*</span>litchiView;<br />
AppleView <span class="sy0">*</span>appleView;<br />
OrangeView <span class="sy0">*</span>orangeView;<br />
StarfruitsView <span class="sy0">*</span>starfruitsView;</p>
<p>UIButton <span class="sy0">*</span>button1;<br />
UIButton <span class="sy0">*</span>button2;<br />
UIButton <span class="sy0">*</span>button3;<br />
UIButton <span class="sy0">*</span>button4;<br />
UIButton <span class="sy0">*</span>button5;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet DetailView <span class="sy0">*</span>detailView;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet LitchiView <span class="sy0">*</span>litchiView;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet AppleView <span class="sy0">*</span>appleView;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet OrangeView <span class="sy0">*</span>orangeView;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet StarfruitsView <span class="sy0">*</span>starfruitsView;</p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet UIButton <span class="sy0">*</span>button1;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet UIButton <span class="sy0">*</span>button2;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet UIButton <span class="sy0">*</span>button3;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet UIButton <span class="sy0">*</span>button4;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet UIButton <span class="sy0">*</span>button5;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>FirstButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>SecondButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>ThirdButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>ForthButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>FifthButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 6:</strong> Double click the FirstView.xib file and open it to the Interface Builder. First drag the navigation bar and give the title &#8220;GridView&#8221;. Drag the five Round Rect Button and place it to the view window. Select first button and bring up Attribute Inspector select the raspberries.png.Do the same thing other four buttons and select the &#8220;litchi.png&#8221;,&#8221;apple.png&#8221;,&#8221;orange.png&#8221; and &#8220;starfruits.png&#8221;. Now Connect the File&#8217;s Owner icon to the first button and select button1, do the same thing for the other buttons and select button2, button3,button4 and button5.  Drag the label from the library and place it below the buttons. Give the label name &#8220;Raspberries&#8221;,&#8221;Litchi&#8221;,&#8221;Apple&#8221;,&#8221;Orange&#8221; and &#8220;Starfruit&#8221; (See the figure 1). Now select the Raspberries button and bring up Connection Inspector and connect Touch Up Inside to the File&#8217;s Owner icon and select FirstButton. Do the same thing for the other buttons also and select SecondButton: , ThirdButton:, FourthButton: and  FifthButton: method. Save the .xib file, close it and go back to the Xcode.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/1-20.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/1-20-300x219.jpg" alt="" title="1-20" width="300" height="219" class="alignnone size-medium wp-image-3010" /></a><br />
<strong>Figure 1</strong></p>
<p><strong>Step 7:</strong> In the FirstViewController.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;FirstViewController.h&quot;</span><br />
<span class="co1">#import &quot;DetailView.h&quot;</span><br />
<span class="co1">#import &quot;LitchiView.h&quot;</span><br />
<span class="co1">#import &quot;AppleView.h&quot;</span><br />
<span class="co1">#import &quot;OrangeView.h&quot;</span><br />
<span class="co1">#import &quot;StarfruitsView.h&quot;</span></p>
<p><span class="kw1">@implementation</span> FirstViewController</p>
<p><span class="kw1">@synthesize</span> button1,button2,button3,button4,button5,detailView,litchiView,appleView,orangeView,starfruitsView;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>FirstButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
detailView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>DetailView alloc<span class="br0">&#93;</span> initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;DetailView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>detailView.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>SecondButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
litchiView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>LitchiView alloc<span class="br0">&#93;</span>initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;LitchiView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>litchiView.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>ThirdButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
appleView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>AppleView alloc<span class="br0">&#93;</span>initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;AppleView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>appleView.view<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>ForthButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
orangeView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>OrangeView alloc<span class="br0">&#93;</span>initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;OrangeView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>orangeView.view<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>FifthButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
starfruitsView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>StarfruitsView alloc<span class="br0">&#93;</span>initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;StarfruitsView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>starfruitsView.view<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="coMULTI">/*<br />
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.<br />
- (void)viewDidLoad<br />
{<br />
[super viewDidLoad];<br />
}<br />
*/</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Return YES for supported orientations</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc. that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any retained subviews of the main view.</span><br />
<span class="co2">// e.g. self.myOutlet = nil;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 8:</strong> Open the DetailView.h file and make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@class</span> FirstViewController;</p>
<p><span class="kw1">@interface</span> DetailView <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>FirstViewController <span class="sy0">*</span>firstViewController;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet FirstViewController <span class="sy0">*</span>firstViewController;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 9:</strong> Double click the DetailView.xib file and open it to the Interface Builder. First drag the NavigationBar from the library and place it to the view window, drag the ImageView from the library and place it to the View window and drag the RoundRect button and place it into the NavigationBar. Select the Round Rect button and bring up Attributes Inspector select the &#8220;backbutton.png&#8221; and bring up Connection Inspector and connect Touch Up Inside to the File&#8217;s Owner icon and select BackButton: method. Select the ImageView and bring up Attributes Inspector and select the &#8220;raspberries-big.png&#8221;(See the figure 2). Save it , close it and go back to the Xcode.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/2-9.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/2-9-300x219.jpg" alt="" title="2-9" width="300" height="219" class="alignnone size-medium wp-image-3011" /></a><br />
<strong>Figure 2</strong><br />
<strong>Step 10: </strong>In the DetailView.m file and make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;DetailView.h&quot;</span><br />
<span class="co1">#import &quot;FirstViewController.h&quot;</span></p>
<p><span class="kw1">@implementation</span> DetailView</p>
<p><span class="kw1">@synthesize</span> firstViewController;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
firstViewController <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>FirstViewController alloc<span class="br0">&#93;</span>initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;FirstView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>firstViewController.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>firstViewController.view release<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>initWithNibName<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>nibNameOrNil bundle<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span class="kw5">NSBundle</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>nibBundleOrNil<br />
<span class="br0">&#123;</span><br />
self <span class="sy0">=</span> <span class="br0">&#91;</span>super initWithNibName<span class="sy0">:</span>nibNameOrNil bundle<span class="sy0">:</span>nibBundleOrNil<span class="br0">&#93;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span>self<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co2">// Custom initialization</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">return</span> self;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="co2">// Do any additional setup after loading the view from its nib.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Return YES for supported orientations</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 11:</strong> Open the LitchiView.h file and make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@class</span> FirstViewController;</p>
<p><span class="kw1">@interface</span> LitchiView <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>FirstViewController <span class="sy0">*</span>firstViewController;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet FirstViewController <span class="sy0">*</span>firstViewController;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 12:</strong> Double click the LitchiView.xib file and open it to the Interface Builder. First drag the NavigationBar from the library and place it to the view window, drag the ImageView from the library and place it to the View window and drag the RoundRect button and place it into the NavigationBar. Select the Round Rect button and bring up Attributes Inspector select the &#8220;backbutton.png&#8221; and bring up Connection Inspector and connect Touch Up Inside to the File&#8217;s Owner icon and select BackButton: method. Select the ImageView and bring up Attributes Inspector and select the &#8220;litchi-big.png&#8221;(See the figure 3). Save it , close it and go back to the Xcode.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/3-4.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/3-4-300x228.jpg" alt="" title="3-4" width="300" height="228" class="alignnone size-medium wp-image-3012" /></a><br />
<strong>Figure 3</strong><br />
<strong>Step 13: </strong>In the LitchiView.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;LitchiView.h&quot;</span><br />
<span class="co1">#import &quot;FirstViewController.h&quot;</span></p>
<p><span class="kw1">@implementation</span> LitchiView</p>
<p><span class="kw1">@synthesize</span> firstViewController;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
firstViewController <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>FirstViewController alloc<span class="br0">&#93;</span>initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;FirstView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>firstViewController.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>firstViewController.view release<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>initWithNibName<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>nibNameOrNil bundle<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span class="kw5">NSBundle</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>nibBundleOrNil<br />
<span class="br0">&#123;</span><br />
self <span class="sy0">=</span> <span class="br0">&#91;</span>super initWithNibName<span class="sy0">:</span>nibNameOrNil bundle<span class="sy0">:</span>nibBundleOrNil<span class="br0">&#93;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span>self<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co2">// Custom initialization</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">return</span> self;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="co2">// Do any additional setup after loading the view from its nib.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="co2">// Release any retained subviews of the main view.</span><br />
<span class="co2">// e.g. self.myOutlet = nil;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Return YES for supported orientations</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 14: </strong>Open the AppleView.h file and make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@class</span> FirstViewController;</p>
<p><span class="kw1">@interface</span> AppleView <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>FirstViewController <span class="sy0">*</span>firstViewController;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet FirstViewController <span class="sy0">*</span>firstViewController;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 15:</strong> Double click the AppleView.xib file and open it to the Interface Builder. First drag the NavigationBar from the library and place it to the view window, drag the ImageView from the library and place it to the View window and drag the RoundRect button and place it into the NavigationBar. Select the Round Rect button and bring up Attributes Inspector select the &#8220;backbutton.png&#8221; and bring up Connection Inspector and connect Touch Up Inside to the File&#8217;s Owner icon and select BackButton: method. Select the ImageView and bring up Attributes Inspector and select the &#8220;litchi-big.png&#8221; (See the figure 4). Save it , close it and go back to the Xcode.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/4-1.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/4-1-300x222.jpg" alt="" title="4-1" width="300" height="222" class="alignnone size-medium wp-image-3013" /></a><br />
<strong>Figure 4</strong><br />
<strong>Step 16:</strong> In the AppleView.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;AppleView.h&quot;</span><br />
<span class="co1">#import &quot;FirstViewController.h&quot;</span></p>
<p><span class="kw1">@implementation</span> AppleView</p>
<p><span class="kw1">@synthesize</span> firstViewController;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
firstViewController <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>FirstViewController alloc<span class="br0">&#93;</span>initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;FirstView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>firstViewController.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>firstViewController.view release<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>initWithNibName<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>nibNameOrNil bundle<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span class="kw5">NSBundle</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>nibBundleOrNil<br />
<span class="br0">&#123;</span><br />
self <span class="sy0">=</span> <span class="br0">&#91;</span>super initWithNibName<span class="sy0">:</span>nibNameOrNil bundle<span class="sy0">:</span>nibBundleOrNil<span class="br0">&#93;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span>self<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co2">// Custom initialization</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">return</span> self;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="co2">// Do any additional setup after loading the view from its nib.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Return YES for supported orientations</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 17:</strong> Open the OrangeView.h file and make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@class</span> FirstViewController;</p>
<p><span class="kw1">@interface</span> OrangeView <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>FirstViewController <span class="sy0">*</span>firstViewController;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet FirstViewController <span class="sy0">*</span>firstViewController;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 18:</strong> Double click the OrangeView.xib file and open it to the Interface Builder. First drag the NavigationBar from the library and place it to the view window, drag the ImageView from the library and place it to the View window and drag the RoundRect button and place it into the NavigationBar. Select the Round Rect button and bring up Attributes Inspector select the &#8220;backbutton.png&#8221; and bring up Connection Inspector and connect Touch Up Inside to the File&#8217;s Owner icon and select BackButton: method. Select the ImageView and bring up Attributes Inspector and select the &#8220;litchi-big.png&#8221; (See the figure 5). Save it , close it and go back to the Xcode.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/5-1.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/5-1-300x221.jpg" alt="" title="5-1" width="300" height="221" class="alignnone size-medium wp-image-3014" /></a><br />
<strong>Figure 5</strong><br />
<strong>Step 19:</strong> In the OrangeView.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;OrangeView.h&quot;</span><br />
<span class="co1">#import &quot;FirstViewController.h&quot;</span></p>
<p><span class="kw1">@implementation</span> OrangeView</p>
<p><span class="kw1">@synthesize</span> firstViewController;</p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
firstViewController <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>FirstViewController alloc<span class="br0">&#93;</span>initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;FirstView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>firstViewController.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>firstViewController.view release<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>initWithNibName<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>nibNameOrNil bundle<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span class="kw5">NSBundle</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>nibBundleOrNil<br />
<span class="br0">&#123;</span><br />
self <span class="sy0">=</span> <span class="br0">&#91;</span>super initWithNibName<span class="sy0">:</span>nibNameOrNil bundle<span class="sy0">:</span>nibBundleOrNil<span class="br0">&#93;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span>self<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co2">// Custom initialization</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">return</span> self;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;</p>
<p><span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="co2">// Do any additional setup after loading the view from its nib.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="co2">// Return YES for supported orientations</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 20:</strong> Open the StarfruitsView.h file and make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@class</span> FirstViewController;</p>
<p><span class="kw1">@interface</span> StarfruitsView <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>FirstViewController <span class="sy0">*</span>firstViewController;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet FirstViewController <span class="sy0">*</span>firstViewController;<br />
<span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 21:</strong> Double click the StarfruitsView.xib file and open it to the Interface Builder. First drag the NavigationBar from the library and place it to the view window, drag the ImageView from the library and place it to the View window and drag the RoundRect button and place it into the NavigationBar. Select the Round Rect button and bring up Attributes Inspector select the &#8220;backbutton.png&#8221; and bring up Connection Inspector and connect Touch Up Inside to the File&#8217;s Owner icon and select BackButton: method. Select the ImageView and bring up Attributes Inspector and select the &#8220;litchi-big.png&#8221; (See the figure 6). Save it , close it and go back to the Xcode.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/6-3.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/6-3-300x226.jpg" alt="" title="6-3" width="300" height="226" class="alignnone size-medium wp-image-3015" /></a><br />
<strong>Figure 6</strong><br />
<strong>Step 22:</strong> In the StarfruitsView.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;StarfruitsView.h&quot;</span><br />
<span class="co1">#import &quot;FirstViewController.h&quot;</span></p>
<p><span class="kw1">@implementation</span> StarfruitsView</p>
<p><span class="kw1">@synthesize</span> firstViewController; </p>
<p><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>BackButton<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; firstViewController <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>FirstViewController alloc<span class="br0">&#93;</span>initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;FirstView&quot;</span>bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>; &nbsp;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>firstViewController.view<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>firstViewController.view release<span class="br0">&#93;</span>;<br />
&nbsp; <br />
<span class="br0">&#125;</span></p>
<p>
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>initWithNibName<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>nibNameOrNil bundle<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span class="kw5">NSBundle</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>nibBundleOrNil<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; self <span class="sy0">=</span> <span class="br0">&#91;</span>super initWithNibName<span class="sy0">:</span>nibNameOrNil bundle<span class="sy0">:</span>nibBundleOrNil<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>self<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// Custom initialization</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> self;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="co2">// Do any additional setup after loading the view from its nib.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
&nbsp;<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 23:</strong> Now Compile and run the application on the Simulator.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/7-1.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/7-1-160x300.jpg" alt="" title="7-1" width="160" height="300" class="alignnone size-medium wp-image-3016" /></a></p>
<p>You can <strong>Download SourceCode </strong>from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/05/GridView.zip'>GridView</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/gridview-using-interface-builder-in-iphone/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Add DatePicker programmatically and display date in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/add-datepicker-programmatically-and-display-date-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/add-datepicker-programmatically-and-display-date-in-iphone/#comments</comments>
		<pubDate>Tue, 24 May 2011 07:53:44 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[Add DatePicker programmatically and display date in iPhone]]></category>
		<category><![CDATA[UIDatePicker Add Programattically]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=2998</guid>
		<description><![CDATA[In this example we will see how to UIDatePicker implement programmatically in the code and display  date on the screen. So let see how it will worked.]]></description>
			<content:encoded><![CDATA[<p>In this example we will see how to UIDatePicker implement programmatically in the code and display  date on the screen. So let see how it will worked.</p>
<p><strong>Step 1: </strong>Open a Xcode, Create a View base application. Give the application name ”DatePickerWithDate”.</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>We need to add one background image in the project. Give the image name &#8220;1.png&#8221;.</p>
<p><strong>Step 4: </strong>Open the DatePickerWithDate.h file and create an instance of UIDatePicker class and  UILabel class. So make the following changes in the file.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@interface</span> DatePickerWithDateViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; IBOutlet UIDatePicker <span class="sy0">*</span>datePicker;<br />
&nbsp; &nbsp; IBOutlet UILabel <span class="sy0">*</span>datelabel;<br />
&nbsp;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> UIDatePicker <span class="sy0">*</span>datePicker;<br />
<span class="kw1">@property</span><span class="br0">&#40;</span>nonatomic,retain<span class="br0">&#41;</span> IBOutlet UILabel <span class="sy0">*</span>datelabel;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 5:</strong> Double click the DatePickerWithDate.xib file open it to the Interface Builder. First drag the imageview from the library and place it to the view window. Select the view and bring up Attribute inspector and select the 1.png. Now save the .xib file save it and go back to the Xcode.</p>
<p><strong>Step 6: </strong>In the DatePickerWithDate.m file make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;DatePickerWithDateViewController.h&quot;</span></p>
<p><span class="kw1">@implementation</span> DatePickerWithDateViewController</p>
<p><span class="kw1">@synthesize</span> datePicker;</p>
<p><span class="kw1">@synthesize</span> datelabel;</p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>datelabel release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#91;</span>datePicker release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co2">// Releases the view if it doesn&#8217;t have a superview.</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co2">// Release any cached data, images, etc that aren&#8217;t in use.</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p>
<span class="co2">// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; datelabel <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UILabel alloc<span class="br0">&#93;</span> init<span class="br0">&#93;</span>; <br />
&nbsp; &nbsp; datelabel.frame <span class="sy0">=</span> CGRectMake<span class="br0">&#40;</span>10, 200, 300, 40<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; datelabel.backgroundColor <span class="sy0">=</span> <span class="br0">&#91;</span>UIColor clearColor<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; datelabel.textColor <span class="sy0">=</span> <span class="br0">&#91;</span>UIColor whiteColor<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; datelabel.font <span class="sy0">=</span> <span class="br0">&#91;</span>UIFont fontWithName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;Verdana-Bold&quot;</span> size<span class="sy0">:</span> 20.0<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; datelabel.textAlignment <span class="sy0">=</span> UITextAlignmentCenter;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/"><span class="kw5">NSDateFormatter</span></a> <span class="sy0">*</span>df <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/NSDateFormatter_Class/"><span class="kw5">NSDateFormatter</span></a> alloc<span class="br0">&#93;</span> init<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; df.dateStyle <span class="sy0">=</span> NSDateFormatterMediumStyle;<br />
&nbsp; &nbsp; &nbsp; &nbsp; datelabel.text <span class="sy0">=</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> stringWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;%@&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>df stringFromDate<span class="sy0">:</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> date<span class="br0">&#93;</span><span class="br0">&#93;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>df release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>datelabel<span class="br0">&#93;</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>datelabel release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; datePicker <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIDatePicker alloc<span class="br0">&#93;</span> initWithFrame<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>0, 250, 325, 300<span class="br0">&#41;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; datePicker.datePickerMode <span class="sy0">=</span> UIDatePickerModeDate;<br />
&nbsp; &nbsp; &nbsp; &nbsp; datePicker.hidden <span class="sy0">=</span> <span class="kw2">NO</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; datePicker.date <span class="sy0">=</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> date<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>datePicker addTarget<span class="sy0">:</span>self<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;action<span class="sy0">:</span><span class="kw1">@selector</span><span class="br0">&#40;</span>LabelChange<span class="sy0">:</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;forControlEvents<span class="sy0">:</span>UIControlEventValueChanged<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>datePicker<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#91;</span>datePicker release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>LabelChange<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/"><span class="kw5">NSDateFormatter</span></a> <span class="sy0">*</span>df <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/NSDateFormatter_Class/"><span class="kw5">NSDateFormatter</span></a> alloc<span class="br0">&#93;</span> init<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; df.dateStyle <span class="sy0">=</span> NSDateFormatterMediumStyle;<br />
&nbsp; &nbsp; &nbsp; &nbsp; datelabel.text <span class="sy0">=</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> stringWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;%@&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>df stringFromDate<span class="sy0">:</span>datePicker.date<span class="br0">&#93;</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p>
<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="co2">// Release any retained subviews of the main view.</span><br />
&nbsp; &nbsp; <span class="co2">// e.g. self.myOutlet = nil;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co2">// Return YES for supported orientations</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 7: </strong>Compile and run the application in the simulator.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/11.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/11-162x300.jpg" alt="" title="1" width="162" height="300" class="alignnone size-medium wp-image-3001" /></a></p>
<p>You can <strong>Download SourceCode</strong> from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/05/DatePickerWithDate.zip'>DatePickerWithDate</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/add-datepicker-programmatically-and-display-date-in-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ImageLoad from Server in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/imageload-from-server-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/imageload-from-server-in-iphone/#comments</comments>
		<pubDate>Wed, 18 May 2011 07:49:35 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Beginner Tutorials]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[ImageLoad From Server]]></category>
		<category><![CDATA[ImageLoad from Server in iPhone]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=2991</guid>
		<description><![CDATA[In this application we will see how to image fetch from the server and place it to the view. I will show you the easiest way for image fetch from server. So let see how it will work.]]></description>
			<content:encoded><![CDATA[<p>In this application we will see how to image fetch from the server and place it to the view. I will show you the easiest way for image fetch from server. So let see how it will work.</p>
<p><strong>Step 1:</strong> Open the Xcode, Create a new project using Window base application. Give the application “imageLoad”.</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> We need to add one ViewController class in the project. So select the project -&gt; New File -&gt; Cocoa Touch -&gt;ViewController class and give the class name “ImageLoadFromServer”.</p>
<p><strong>Step 4:</strong> Open the ImageLoadAppDelegate.h file, we need to define ImageLoadFromServer class and create an instance of ImageLoadFromServer class. So make the following changes in the file.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span><br />
<span class="kw1">@class</span> ImageLoadFromServer;</p>
<p><span class="kw1">@interface</span> ImageLoadAppDelegate <span class="sy0">:</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span class="kw5">NSObject</span></a> &nbsp;<span class="br0">&#123;</span><br />
ImageLoadFromServer <span class="sy0">*</span>imageLoadFromServer;<br />
<span class="br0">&#125;</span><br />
<span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet UIWindow <span class="sy0">*</span>window;<br />
<span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet ImageLoadFromServer <span class="sy0">*</span>imageLoadFromServer;</p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 5:</strong> Now make the following changes in the ImageLoadAppDelegate.m file.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;ImageLoadAppDelegate.h&quot;</span><br />
<span class="co1">#import &quot;ImageLoadFromServer.h&quot;</span></p>
<p><span class="kw1">@implementation</span> ImageLoadAppDelegate</p>
<p><span class="kw1">@synthesize</span> window<span class="sy0">=</span>_window;<br />
<span class="kw1">@synthesize</span> imageLoadFromServer;</p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>application<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application didFinishLaunchingWithOptions<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span class="kw5">NSDictionary</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>launchOptions<br />
<span class="br0">&#123;</span></p>
<p>imageLoadFromServer <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>ImageLoadFromServer alloc<span class="br0">&#93;</span> init<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>_window addSubview<span class="sy0">:</span>imageLoadFromServer.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.window makeKeyAndVisible<span class="br0">&#93;</span>;<br />
<span class="kw1">return</span> <span class="kw2">YES</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationWillResignActive<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span></p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationDidEnterBackground<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span></p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationWillEnterForeground<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span></p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationDidBecomeActive<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span></p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationWillTerminate<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application<br />
<span class="br0">&#123;</span></p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>_window release<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 6: </strong> Open the ImageLoadFromServer.h file and create an instance of UIImageView. So make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &lt;UIKit/UIKit.h&gt;</span></p>
<p><span class="kw1">@interface</span> ImageLoadFromServer <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>UIImageView <span class="sy0">*</span>imageLoad;</p>
<p><span class="br0">&#125;</span><br />
<span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet UIImageView <span class="sy0">*</span>imageLoad;<br />
<span class="kw1">@end</span></div>
</div>
<p><strong>Step 7:</strong> In the ImageLoadFromServer.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#import &quot;ImageLoadFromServer.h&quot;</span><br />
<span class="kw1">@implementation</span> ImageLoadFromServer<br />
<span class="kw1">@synthesize</span> imageLoad;</p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>initWithNibName<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>nibNameOrNil bundle<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span class="kw5">NSBundle</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>nibBundleOrNil<br />
<span class="br0">&#123;</span><br />
self <span class="sy0">=</span> <span class="br0">&#91;</span>super initWithNibName<span class="sy0">:</span>nibNameOrNil bundle<span class="sy0">:</span>nibBundleOrNil<span class="br0">&#93;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span>self<span class="br0">&#41;</span> <span class="br0">&#123;</span></p>
<p><span class="br0">&#125;</span></p>
<p><span class="kw1">return</span> self;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>imageLoad release<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>super dealloc<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>didReceiveMemoryWarning<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super didReceiveMemoryWarning<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="co1">#pragma mark &#8211; View lifecycle</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;</p>
<p><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span class="kw5">NSURL</span></a> <span class="sy0">*</span>imageurl <span class="sy0">=</span> <span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span class="kw5">NSURL</span></a> URLWithString<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;http://www.chakrainteractive.com/mob/ImageUpoad/pic2-2.png&quot;</span><span class="br0">&#93;</span>;<br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/"><span class="kw5">NSData</span></a> <span class="sy0">*</span>imagedata <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/NSData_Class/"><span class="kw5">NSData</span></a> alloc<span class="br0">&#93;</span>initWithContentsOfURL<span class="sy0">:</span>imageurl<span class="br0">&#93;</span>;<br />
UIImage <span class="sy0">*</span>image <span class="sy0">=</span> <span class="br0">&#91;</span>UIImage imageWithData<span class="sy0">:</span> imagedata<span class="br0">&#93;</span>;<br />
imageLoad <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIImageView alloc<span class="br0">&#93;</span> initWithImage<span class="sy0">:</span> image<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>imageLoad<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidUnload<br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>super viewDidUnload<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>shouldAutorotateToInterfaceOrientation<span class="sy0">:</span><span class="br0">&#40;</span>UIInterfaceOrientation<span class="br0">&#41;</span>interfaceOrientation<br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>interfaceOrientation <span class="sy0">==</span> UIInterfaceOrientationPortrait<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">@end</span></div>
</div>
<p><strong>Step 8:</strong> Now compile and run the application in the Simulator.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/1-171.jpg"><img src="http://www.edumobile.org/iphone/wp-content/uploads/2011/05/1-171-168x300.jpg" alt="" title="1-17" width="168" height="300" class="alignnone size-medium wp-image-2995" /></a></p>
<p>You can <strong>Download SourceCode</strong> from here <a href='http://www.edumobile.org/iphone/wp-content/uploads/2011/05/ImageLoad.zip'>ImageLoad</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/imageload-from-server-in-iphone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

