<?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 development</title>
	<atom:link href="http://www.edumobile.org/iphone/tag/iphone-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.edumobile.org/iphone</link>
	<description></description>
	<lastBuildDate>Wed, 25 Jan 2012 09:42:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Calculate StringLength in MacOS</title>
		<link>http://www.edumobile.org/iphone/iphone-trends-stats/calculate-stringlength-in-macos/</link>
		<comments>http://www.edumobile.org/iphone/iphone-trends-stats/calculate-stringlength-in-macos/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 10:43:14 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Trends & Stats]]></category>
		<category><![CDATA[Calculate StringLength in MacOS]]></category>
		<category><![CDATA[iphone development]]></category>
		<category><![CDATA[iPhone example]]></category>

		<guid isPermaLink="false">http://www.edumobile.org/iphone/?p=2693</guid>
		<description><![CDATA[This is the very simple example, in this program we will see how to calculate string length in MacOS.]]></description>
			<content:encoded><![CDATA[<p>This is the very simple example, in this program we will see how to calculate string length in MacOS.</p>
<p><strong>Step 1:</strong> Create a Cocoa Application from Mac OS X . Give the application name &#8220;StringsLength&#8221;.</p>
<p><strong>Step 2:</strong> Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.</p>
<p><strong>Step 3:</strong> xpand the Other  Sources folder, then  you can see one file &#8220;main.m&#8221;. We need to make changes in this file.</p>
<p><strong>Step 4:</strong> Open the main.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 &lt;Cocoa/Cocoa.h&gt;</span></p>
<p>&nbsp;<span class="kw4">int</span> main<span class="br0">&#40;</span><span class="kw4">int</span> argc, <span class="kw4">char</span> <span class="sy0">*</span>argv<span class="br0">&#91;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><br />
&nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">char</span> s1<span class="br0">&#91;</span>250<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">char</span> s2<span class="br0">&#91;</span>250<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span class="kw3">printf</span></a><span class="br0">&#40;</span><span class="st0">&quot;Enter string s1:<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/scanf.html"><span class="kw3">scanf</span></a><span class="br0">&#40;</span><span class="st0">&quot;%s&quot;</span>,<span class="sy0">&amp;</span>s1<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span class="kw3">printf</span></a><span class="br0">&#40;</span><span class="st0">&quot;Enter string s2:<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/scanf.html"><span class="kw3">scanf</span></a><span class="br0">&#40;</span><span class="st0">&quot;%s&quot;</span>,<span class="sy0">&amp;</span>s2<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.opengroup.org/onlinepubs/009695399/functions/strlen.html"><span class="kw3">strlen</span></a><span class="br0">&#40;</span>s1<span class="br0">&#41;</span> <span class="sy0">==</span> <a href="http://www.opengroup.org/onlinepubs/009695399/functions/strlen.html"><span class="kw3">strlen</span></a><span class="br0">&#40;</span>s2<span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span class="kw3">printf</span></a><span class="br0">&#40;</span><span class="st0">&quot;Length of string s1 is equal to length of string s2<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span> <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.opengroup.org/onlinepubs/009695399/functions/strlen.html"><span class="kw3">strlen</span></a><span class="br0">&#40;</span>s1<span class="br0">&#41;</span> &lt; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/strlen.html"><span class="kw3">strlen</span></a><span class="br0">&#40;</span>s2<span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span class="kw3">printf</span></a><span class="br0">&#40;</span><span class="st0">&quot;Length of string s1 is less than length of string s2<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span class="kw3">printf</span></a><span class="br0">&#40;</span><span class="st0">&quot;Length of string s1 is greater than length of string s2<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> NSApplicationMain<span class="br0">&#40;</span>argc, &nbsp;<span class="br0">&#40;</span><span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">**</span><span class="br0">&#41;</span> argv<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 5:</strong> Now compile and run the example and see the output on the console.</p>
<p><a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/02/1-7.jpg"><img class="alignnone size-medium wp-image-2696" title="1-7" src="http://www.edumobile.org/iphone/wp-content/uploads/2011/02/1-7-300x114.jpg" alt="" width="300" height="114" /></a></p>
<p>You can <strong>Download SourceCode</strong> from here <a href="http://www.edumobile.org/iphone/wp-content/uploads/2011/02/StringsLength.zip">StringsLength</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-trends-stats/calculate-stringlength-in-macos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use UIWebView using Utility Application in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-use-uiwebview-using-utility-application-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-use-uiwebview-using-utility-application-in-iphone/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 11:22:07 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[How to use UIWebView using Utility Application in iPhone]]></category>
		<category><![CDATA[iphone development]]></category>
		<category><![CDATA[UIWebView]]></category>

		<guid isPermaLink="false">http://edumobile.org/iphone/?p=1459</guid>
		<description><![CDATA[In this application we will see how to use UIWebView using Utility Application. When user click the Dark info Button in the Web page, it will display the next screen where text will be display. This is very simple example. Let see how it will be work.]]></description>
			<content:encoded><![CDATA[<p>In this application we will see how to use UIWebView using Utility Application. When user click the Dark info Button in the Web page, it will display the next screen where text will be display. This is very simple example. Let see how it will be worked.</p>
<p><strong>Step 1:</strong> Create a Window base application using template . Give the example name &#8220;WebWithUtilityApplication&#8221;.</p>
<p><strong>Step 2:</strong> Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.</p>
<p><strong>Step 3:</strong> We need to add here three UIViewController class to the project.Choose New file -> Select cocoa touch classes group and then select UIViewController subclass. Give the name “RootViewViewController”,&#8221;MainViewController&#8221; and &#8220;FlipsideViewontroller&#8221;. Now add two UIView class to the project.Choose New file -> Select cocoa touch classes group and then select UIView subclass and corresponding .xib file.Give the name “MainView” and &#8220;FlipsideView&#8221;.</p>
<p><strong>Step 4</strong>: In the AppDelegate.h file, we have added &#8220;RootViewController&#8221; class</p>
<p><strong>Step 5: </strong>Make the following changes in the AppDelegate.m file :</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationDidFinishLaunching<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application <span class="br0">&#123;</span><br />
&nbsp; <span class="br0">&#91;</span>window addSubview<span class="sy0">:</span><span class="br0">&#91;</span>rootViewController view<span class="br0">&#93;</span><span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>window makeKeyAndVisible<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 6: </strong>In the RootViewController.h file, add MainViewController and FlipsideViewControlller class, UIButton and UINavigationBar. Define one IBAction method. So make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="kw1">@class</span> MainViewController;<br />
&nbsp; <span class="kw1">@class</span> FlipsideViewController;</p>
<p>&nbsp; <span class="kw1">@interface</span> RootViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>&nbsp; MainViewController <span class="sy0">*</span>mainViewController;<br />
&nbsp; FlipsideViewController <span class="sy0">*</span>flipSideViewController;<br />
&nbsp; IBOutlet UIButton <span class="sy0">*</span>displayButton;<br />
&nbsp; UINavigationBar <span class="sy0">*</span>navigationBar;<br />
<span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> MainViewController <span class="sy0">*</span>mainViewController;<br />
&nbsp; <span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> FlipsideViewController <span class="sy0">*</span>flipSideViewController;<br />
&nbsp; <span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> UIButton <span class="sy0">*</span>displayButton;<br />
&nbsp; <span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> UINavigationBar <span class="sy0">*</span>navigationBar;</p>
<p><span class="sy0">-</span> <span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>toggleView;</div>
</div>
<p><strong>Step 7:</strong> Double click your MainWindow.xib file and open it to the Interface Builder. Drag ViewController from the library and place it to the view window. Select ViewController and bring up Identity Inspector, change the class name into RootViewController. After that, drag the view from the library and place it to the view controller and drag button from library and place it to the view window. Select the Button and bring up Attribute inspector, change the type into Dark info. Select the RootViewController icon and bring up Connection Inspector drag from the displayButton to Dark info button and drag toggleView to the Dark info button and select TouchUpInside. Now save it, close it, and go back to the Xcode.</p>
<p><strong>Step 8:</strong> In the RootViewController.m file, make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><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; MainViewController <span class="sy0">*</span>viewController <span class="sy0">=</span><span class="br0">&#91;</span><span class="br0">&#91;</span>MainViewController alloc<span class="br0">&#93;</span>   &nbsp; initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;MainView&quot;</span> bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
&nbsp; self.mainViewController <span class="sy0">=</span> viewController;<br />
&nbsp; <span class="br0">&#91;</span>viewController release<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>self.view insertSubview<span class="sy0">:</span>mainViewController.view &nbsp; belowSubview<span class="sy0">:</span>displayButton<span class="br0">&#93;</span>;</p>
<p>&nbsp; <span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p>&nbsp; <span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>loadFlipsideViewController <span class="br0">&#123;</span></p>
<p>&nbsp; FlipsideViewController <span class="sy0">*</span>viewController <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>FlipsideViewController alloc<span class="br0">&#93;</span>   initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;FlipsideView&quot;</span> bundle<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
&nbsp; self.flipSideViewController <span class="sy0">=</span> viewController;<br />
&nbsp; <span class="br0">&#91;</span>viewController release<span class="br0">&#93;</span>;</p>
<p>&nbsp; UINavigationBar <span class="sy0">*</span>aNavigationBar <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UINavigationBar alloc<span class="br0">&#93;</span>   initWithFrame<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>0.0, 0.0, 320.0, 44.0<span class="br0">&#41;</span><span class="br0">&#93;</span>;<br />
&nbsp; aNavigationBar.barStyle <span class="sy0">=</span> UIBarStyleBlackOpaque;<br />
&nbsp; self.navigationBar <span class="sy0">=</span> aNavigationBar;<br />
&nbsp; <span class="br0">&#91;</span>aNavigationBar release<span class="br0">&#93;</span>;</p>
<p>&nbsp; UIBarButtonItem <span class="sy0">*</span>buttonItem <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIBarButtonItem alloc<span class="br0">&#93;</span>   &nbsp;initWithBarButtonSystemItem<span class="sy0">:</span>UIBarButtonSystemItemDone target<span class="sy0">:</span>self   action<span class="sy0">:</span><span class="kw1">@selector</span><span class="br0">&#40;</span>toggleView<span class="br0">&#41;</span><span class="br0">&#93;</span>;<br />
&nbsp; UINavigationItem <span class="sy0">*</span>navigationItem <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UINavigationItem alloc<span class="br0">&#93;</span>   initWithTitle<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;Information&quot;</span><span class="br0">&#93;</span>;<br />
navigationItem.rightBarButtonItem <span class="sy0">=</span> buttonItem;<br />
&nbsp; <span class="br0">&#91;</span>navigationBar pushNavigationItem<span class="sy0">:</span>navigationItem animated<span class="sy0">:</span><span class="kw2">NO</span><span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>navigationItem release<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>buttonItem release<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p>&nbsp; <span class="sy0">-</span> <span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>toggleView <span class="br0">&#123;</span></p>
<p>&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>flipSideViewController <span class="sy0">==</span> <span class="kw2">nil</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="br0">&#91;</span>self loadFlipsideViewController<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p>&nbsp; UIView <span class="sy0">*</span>mainView <span class="sy0">=</span> mainViewController.view;<br />
&nbsp; UIView <span class="sy0">*</span>flipsideView <span class="sy0">=</span> flipSideViewController.view;</p>
<p>&nbsp; <span class="br0">&#91;</span>UIView beginAnimations<span class="sy0">:</span><span class="kw2">nil</span> context<span class="sy0">:</span><span class="kw2">NULL</span><span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>UIView setAnimationDuration<span class="sy0">:</span>1<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>UIView setAnimationTransition<span class="sy0">:</span><span class="br0">&#40;</span><span class="br0">&#91;</span>mainView superview<span class="br0">&#93;</span> ?   &nbsp; UIViewAnimationTransitionFlipFromRight <span class="sy0">:</span>   &nbsp; UIViewAnimationTransitionFlipFromLeft<span class="br0">&#41;</span> forView<span class="sy0">:</span>self.view cache<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;</p>
<p>&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#91;</span>mainView superview<span class="br0">&#93;</span> <span class="sy0">!=</span> <span class="kw2">nil</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="br0">&#91;</span>flipSideViewController viewWillAppear<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>mainViewController viewWillDisappear<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>mainView removeFromSuperview<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>displayButton removeFromSuperview<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>flipsideView<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>self.view insertSubview<span class="sy0">:</span>navigationBar aboveSubview<span class="sy0">:</span>flipsideView<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>mainViewController viewDidDisappear<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>flipSideViewController viewDidAppear<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;</p>
<p><span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="br0">&#91;</span>mainViewController viewWillAppear<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>flipSideViewController viewWillDisappear<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>flipsideView removeFromSuperview<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>navigationBar removeFromSuperview<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>mainView<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>self.view insertSubview<span class="sy0">:</span>displayButton &nbsp;aboveSubview<span class="sy0">:</span>mainViewController.view<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>flipSideViewController viewDidDisappear<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>mainViewController viewDidAppear<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#91;</span>UIView commitAnimations<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 9:</strong> Open the MainViewController.h file and add UIWebView for display the webview. So make the following changes in the file:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="kw1">@interface</span> MainViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>&nbsp; IBOutlet UIWebView <span class="sy0">*</span>displayWeb;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 10:</strong> Double click the MainView.xib file and open it to the Interface Builder. Select View icon from the Main Window and bring up Identity Inspector, change the class name into MainView, and now select File&#8217;s Owner icon and bring up Identity Inspector change the class name into the MainViewController class. Drag WebView from the library and place it to the view window. Connect File&#8217;s Owner icon to the Main View icon and select view. Next connect File&#8217;s Owner icon to the WebView and select displayWeb. Now save it. close it and go back to the Xcode.</p>
<p><strong>Step 11 :</strong> Open the MainViewController.m file and make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad <span class="br0">&#123;</span><br />
&nbsp; displayWeb.userInteractionEnabled <span class="sy0">=</span> <span class="kw2">true</span>;<br />
&nbsp; <span class="br0">&#91;</span>displayWeb loadRequest<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/NSURLRequest_Class/"><span class="kw5">NSURLRequest</span></a> alloc<span class="br0">&#93;</span> initWithURL<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/NSURL_Class/"><span class="kw5">NSURL</span></a> alloc<span class="br0">&#93;</span>   initWithString<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;http://www.google.com&quot;</span><span class="br0">&#93;</span><span class="br0">&#93;</span><span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 12:</strong> Open the FlipsideView.xib file in the Interface Builder. Select the view icon from the main window and bring up Identity Inspector, change the class name into FlipsideView. Next select the File&#8217;s Owner icon from the library and bring up Identity Inspector, change the class name into the FlipsideViewController. Drag Label from the  library and place it to the view window. Select the label and bring up Attribute Inspector and change the text whatever you want to display. Now save it , close it , and go back to the Xcode.</p>
<p><strong>Step 13:</strong> Now compile and run the application in the simulator.</p>
<p><a href="http://edumobile.org/iphone/wp-content/uploads/2010/03/web-1.jpg"><img src="http://edumobile.org/iphone/wp-content/uploads/2010/03/web-1-168x300.jpg" alt="" title="web-1" width="168" height="300" class="alignnone size-medium wp-image-1473" /></a></p>
<p>You can <strong>downloaded SourceCode</strong> from here <a href='http://edumobile.org/iphone/wp-content/uploads/2010/03/WebWithUtilityApplication-2.zip'>WebWithUtilityApplication 2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-use-uiwebview-using-utility-application-in-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use UIImageView to View in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-use-uiimageview-to-view-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-use-uiimageview-to-view-in-iphone/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 13:39:27 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[How to use UIImageView to View in iPhone]]></category>
		<category><![CDATA[iphone development]]></category>
		<category><![CDATA[UIImage using]]></category>

		<guid isPermaLink="false">http://edumobile.org/iphone/?p=1411</guid>
		<description><![CDATA[In this application we will see , how to use UIImagesView to view without using Interface Builder. Basically images are working with an infinite loop . Just have a look.]]></description>
			<content:encoded><![CDATA[<p>In this application we will see , how to use UIImagesView to view without using Interface Builder. Basically images are working with an infinite loop . Just have a look.</p>
<p><strong>Step 1:</strong> Create a View base application using template. Give the application name &#8220;Animation&#8221;.</p>
<p><strong>Step 2:</strong> Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.</p>
<p><strong>Step 3:</strong> We need to add the resources file called as “1.gif”, &#8220;2.gif&#8221; , &#8220;3.gif&#8221;,  &#8221;4.gif&#8221;, &#8220;5.gif&#8221;, &#8220;6.gif&#8221; into the resource folder. Select resources and add files existing sources.</p>
<p><strong>Step 4:</strong> Open the AnimationViewController.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="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;UIImageView<span class="sy0">*</span>animationView <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>self.view.frame<span class="br0">&#93;</span>;<br />
&nbsp; animationView.animationImages <span class="sy0">=</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> arrayWithObjects<span class="sy0">:</span>&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;1.gif&quot;</span><span class="br0">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;2.gif&quot;</span><span class="br0">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;3.gif&quot;</span><span class="br0">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;4.gif&quot;</span><span class="br0">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;5.gif&quot;</span><span class="br0">&#93;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;6.gif&quot;</span><span class="br0">&#93;</span>, <span class="kw2">nil</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; animationView.animationDuration <span class="sy0">=</span> <span class="nu0">1.25</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; animationView.animationRepeatCount <span class="sy0">=</span> <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>animationView startAnimating<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>self.view addSubview<span class="sy0">:</span>animationView<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>animationView release<span class="br0">&#93;</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; <span class="br0">&#125;</span></div>
</div>
<p><strong>Step 5:</strong> Now compile and run the application in the Simulator.</p>
<p><a href="http://edumobile.org/iphone/wp-content/uploads/2010/03/animation-1.jpg"><img src="http://edumobile.org/iphone/wp-content/uploads/2010/03/animation-1-166x300.jpg" alt="" title="animation-1" width="166" height="300" class="alignnone size-medium wp-image-1415" /></a></p>
<p>You can <strong>downloaded SourceCode</strong> from here <a href='http://edumobile.org/iphone/wp-content/uploads/2010/03/Animation-2.zip'>Animation 2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-use-uiimageview-to-view-in-iphone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Display Datepicker SingleComponentpicker and Doublecomponentpicker with each of the tabbar in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/display-datepicker-singlecomponentpicker-and-doublecomponentpicker-with-each-of-the-tabbar-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/display-datepicker-singlecomponentpicker-and-doublecomponentpicker-with-each-of-the-tabbar-in-iphone/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 14:50:55 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[Display Datepicker SingleComponentpicker and Doublecomponentpicker with each of the tabbar in iPhone]]></category>
		<category><![CDATA[iphone development]]></category>
		<category><![CDATA[Picker Component]]></category>
		<category><![CDATA[Tabbar example]]></category>

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

		<guid isPermaLink="false">http://edumobile.org/iphone/?p=1278</guid>
		<description><![CDATA[In this application we will see how to add a TabBarController as a subview , and when we press Home button in the tab bar it will display the MainView.]]></description>
			<content:encoded><![CDATA[<p>In this application we will see how to add a TabBarController as a subview , and when we press Home button in the tab bar it will display the MainView.</p>
<p><strong>Step 1: </strong>Create a Window base application using the template. Give the application name &#8220;TabBar&#8221;.</p>
<p><strong>Step 2:</strong> Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.</p>
<p><strong>Step 3:</strong> Before we begin to write code, we need to create a couple of ViewControllers. Press ⌘ &#8211; N, select UIViewController subclass and only check the With XIB for user interface. Name it RootViewController, add another viewcontroller, name it TabBarViewController with XIB file.</p>
<p><strong>Step 4:</strong> In the AppDelegate.h file, we have added UINavigationController. So make the following changes in the file.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="kw1">@interface</span> TabBarAppDelegate <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; UIWindow <span class="sy0">*</span>window;<br />
&nbsp; UINavigationController <span class="sy0">*</span>navigationController;<br />
<span class="br0">&#125;</span><br />
&nbsp; <span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> 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 UINavigationController <span class="sy0">*</span>navigationController;</div>
</div>
<p><strong>Step 5: </strong>Double click your MainWindow.xib file and open it to the Interface Builder. Drag the NavigationController from the library and place it to the main window. Now select view controller and bring up Identity Inspector change the class name into the RootViewController. Select RootViewController and bring up Attribute Inspector change the NIB file into the RootViewController.xib . Now save the xib file and go back to the Xcode.</p>
<p><strong>Step 6:</strong> In the AppDelegate.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationDidFinishLaunching<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="br0">&#91;</span>window addSubview<span class="sy0">:</span><span class="br0">&#91;</span>navigationController view<span class="br0">&#93;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;<span class="br0">&#91;</span>window makeKeyAndVisible<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 7: </strong>In the RootViewController.h file we have added TabBarViewController, and UIWebView for display the web view. Mention one method for switch to the another view. Make the following changes :</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="kw1">@interface</span> RootViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span><br />
&nbsp; TabBarViewController <span class="sy0">*</span>tabBarViewController;<br />
&nbsp; IBOutlet UIWebView <span class="sy0">*</span>webDisplay;<br />
<span class="br0">&#125;</span><br />
&nbsp; <span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet UIWebView <span class="sy0">*</span>webDisplay;<br />
&nbsp; <span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> TabBarViewController <span class="sy0">*</span>tabBarViewController;</p>
<p>&nbsp; <span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>switchPage<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</div>
</div>
<p><strong>Step 8:</strong> Now double click your RootViewController.xib file and open it to the Interface Builder. Drag web view from the library and place it to the view window. Now drag Round Rect from the library and place it to the view window. Select File&#8217;s Owner icon and bring up connection inspector select webDisplay to the WebView. Now select Round Rect button and bring up connection inspector drag TouchUpInside to the File&#8217;s Owner icon and select switchPage: action. Save it and go back to the Xcode.</p>
<p><strong>Step 9:</strong> Make the changes in the RootViewController.m file.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span><span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>switchPage<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender<br />
&nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>self.tabBarViewController <span class="sy0">==</span> <span class="kw2">nil</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; TabBarViewController <span class="sy0">*</span>tabBar <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>TabBarViewController alloc<span class="br0">&#93;</span><br />
&nbsp; initWithNibName<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;TabBarViewController&quot;</span> bundle<span class="sy0">:</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><span class="br0">&#93;</span>;<br />
&nbsp; self.tabBarViewController <span class="sy0">=</span> tabBar;<br />
&nbsp; <span class="br0">&#91;</span>tabBar release<span class="br0">&#93;</span>;<br />
&nbsp; presentModalViewController<span class="sy0">:</span>tabBarViewController animated<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
&nbsp;<span class="br0">&#91;</span>self.navigationController pushViewController<span class="sy0">:</span>self.tabBarViewController animated<span class="sy0">:</span><span class="kw2">YES</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>viewDidLoad <span class="br0">&#123;</span></p>
<p>&nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>urlAddress <span class="sy0">=</span> <span class="co3">@</span><span class="st0">&quot;http://www.google.com&quot;</span>;<br />
&nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span class="kw5">NSURL</span></a> <span class="sy0">*</span>url <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>urlAddress<span class="br0">&#93;</span>;<br />
&nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/"><span class="kw5">NSURLRequest</span></a> <span class="sy0">*</span>requestObj <span class="sy0">=</span> <span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/"><span class="kw5">NSURLRequest</span></a> requestWithURL<span class="sy0">:</span>url<span class="br0">&#93;</span>;<br />
&nbsp; <span class="br0">&#91;</span>webDisplay loadRequest<span class="sy0">:</span>requestObj<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;<span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 10:</strong> In the TabBarViewController.h file we have added UITabBarController. make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="kw1">@interface</span> TabBarViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span><br />
&nbsp; IBOutlet UITabBarController <span class="sy0">*</span>tabBarController;<br />
<span class="br0">&#125;</span></p>
<p>&nbsp;<span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet UITabBarController <span class="sy0">*</span>tabBarController;</div>
</div>
<p><strong>Step 11: </strong>Double click your TabBarViewController.xib file and open it to the Interface Builder. Drag TabBarController from the library and place it to the main window. Open the TabBarController and select the Item1 and bring up Attribute Inspector change the NIB name into the RootViewController.xib file . So when you Tab the Item1 it will show the 1st page that is web page. Now save the TabBarViewController.xib file and go back to the Xcode.</p>
<p><strong>Step 12:</strong> Save your code , compile and  the run application on the simulator.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/adding-a-tabbarcontroller-as-a-subview-in-iphone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Implement Scrolling in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/impliment-scrolling-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/impliment-scrolling-in-iphone/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 13:59:35 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[Implement Scrolling]]></category>
		<category><![CDATA[Implement Scrolling in iPhone]]></category>
		<category><![CDATA[iphone development]]></category>

		<guid isPermaLink="false">http://edumobile.org/iphone/?p=1164</guid>
		<description><![CDATA[In this application we will see how to implement two different style UIScrollViews. The first scroller contains multiple images, showing how to layout large content with multiple chunks of data.]]></description>
			<content:encoded><![CDATA[<p>In this application we will see how to implement two different style UIScrollViews. The first scroller contains multiple images, showing how to layout large content with multiple chunks of data.</p>
<p><strong>Step 1:</strong> Create a Window base application using template. Give the application name Scroll 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> Now we’ll add view controller class to the project. Choose New file -&gt; Select cocoa touch classes group and then select UIViewController subclass. Give the name Scroll ImageViewController.</p>
<p><strong>Step 4:</strong> In the AppDelegate.h file, we add the Scroll_ImageViewController, make the following changes in the header file.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="kw1">@interface</span> Scroll_ImageAppDelegate <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></p>
<p>IBOutlet UIWindow <span class="sy0">*</span>window;<br />
IBOutlet Scroll_ImageViewController <span class="sy0">*</span>scrollViewController;<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 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 Scroll_ImageViewController <span class="sy0">*</span>scrollViewController;</div>
</div>
<p><strong>Step 5:</strong> In the AppDelegate.m file make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>dealloc <span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>window release<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>scrollViewController 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>applicationDidFinishLaunching<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application <span class="br0">&#123;</span></p>
<p><span class="br0">&#91;</span>window addSubview<span class="sy0">:</span>scrollViewController.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>window makeKeyAndVisible<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 6:</strong> We are added UIScrollView in the Scroll ImageViewController.h file. Make the following changes.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="kw1">@interface</span> Scroll_ImageViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span></p>
<p>IBOutlet UIScrollView <span class="sy0">*</span>scrollView1;<br />
IBOutlet UIScrollView <span class="sy0">*</span>scrollView2;</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> UIView <span class="sy0">*</span>scrollView1;<br />
<span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> UIView <span class="sy0">*</span>scrollView2;</div>
</div>
<p><strong>Step 7:</strong> Now double click the MainWindow.xib file and open it to the Interface Builder. Drag ViewController from the library and place it to the main window. Select the viewcontroller icon and bring up Identity Inspector  change the class name  into the Scroll ImageViewController. Open the view window , drag view from the library and place it to the view window. Drag scroll image from the library and place it on the view window (See the figure below). Connect Scroll_ImageAppDelegate to the Scroll_ImageViewController . We are added two UIScrollView in the View window. Select one UIScrollView and bring up connection Inspector connect scrollView1 to the Scroll_ImageViewController. Do it once more time for scrollView2. Now save the .xib file and go back to the Xcode.</p>
<p><a href="http://edumobile.org/iphone/wp-content/uploads/2010/03/scroll_IB.jpg"><img class="alignnone size-medium wp-image-1175" title="scroll_IB" src="http://edumobile.org/iphone/wp-content/uploads/2010/03/scroll_IB-190x300.jpg" alt="" width="190" height="300" /></a></p>
<p><strong>Step 8:</strong> Make the following changes in the Scroll ImageViewController.m file.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>layoutScrollImages<br />
<span class="br0">&#123;</span><br />
UIImageView <span class="sy0">*</span>view <span class="sy0">=</span> <span class="kw2">nil</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>subviews <span class="sy0">=</span> <span class="br0">&#91;</span>scrollView1 subviews<span class="br0">&#93;</span>;<br />
CGFloat curXLoc <span class="sy0">=</span> <span class="nu0">0</span>;<br />
<span class="kw1">for</span> <span class="br0">&#40;</span>view <span class="kw1">in</span> subviews<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#91;</span>view isKindOfClass<span class="sy0">:</span><span class="br0">&#91;</span>UIImageView class<span class="br0">&#93;</span><span class="br0">&#93;</span> <span class="sy0">&amp;</span>amp;<span class="sy0">&amp;</span>amp; view.tag <span class="sy0">&amp;</span>gt; 0<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
CGRect frame <span class="sy0">=</span> view.frame;<br />
frame.origin <span class="sy0">=</span> CGPointMake<span class="br0">&#40;</span>curXLoc, 0<span class="br0">&#41;</span>;<br />
view.frame <span class="sy0">=</span> frame;</p>
<p>curXLoc <span class="sy0">+=</span> <span class="br0">&#40;</span>kScrollObjWidth<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="br0">&#91;</span>scrollView1 setContentSize<span class="sy0">:</span>CGSizeMake<span class="br0">&#40;</span><span class="br0">&#40;</span>kNumImages <span class="sy0">*</span> kScrollObjWidth<span class="br0">&#41;</span>, <span class="br0">&#91;</span>scrollView1 bounds<span class="br0">&#93;</span>.size.height<span class="br0">&#41;</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>viewDidLoad<br />
<span class="br0">&#123;</span><br />
self.view.backgroundColor <span class="sy0">=</span> <span class="br0">&#91;</span>UIColor viewFlipsideBackgroundColor<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#91;</span>scrollView1 setBackgroundColor<span class="sy0">:</span><span class="br0">&#91;</span>UIColor blackColor<span class="br0">&#93;</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>scrollView1 setCanCancelContentTouches<span class="sy0">:</span><span class="kw2">NO</span><span class="br0">&#93;</span>;<br />
scrollView1.indicatorStyle <span class="sy0">=</span> UIScrollViewIndicatorStyleWhite;<br />
scrollView1.clipsToBounds <span class="sy0">=</span> <span class="kw2">YES</span>;<br />
scrollView1.scrollEnabled <span class="sy0">=</span> <span class="kw2">YES</span>;</p>
<p>scrollView1.pagingEnabled <span class="sy0">=</span> <span class="kw2">YES</span>;</p>
<p>NSUInteger i;<br />
<span class="kw1">for</span> <span class="br0">&#40;</span>i <span class="sy0">=</span> <span class="nu0">1</span>; i <span class="sy0">&amp;</span>lt;<span class="sy0">=</span> kNumImages; i<span class="sy0">++</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</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>imageName <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;image%d.jpg&quot;</span>, i<span class="br0">&#93;</span>;<br />
UIImage <span class="sy0">*</span>image <span class="sy0">=</span> <span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span>imageName<span class="br0">&#93;</span>;<br />
UIImageView <span class="sy0">*</span>imageView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIImageView alloc<span class="br0">&#93;</span> initWithImage<span class="sy0">:</span>image<span class="br0">&#93;</span>;</p>
<p>CGRect rect <span class="sy0">=</span> imageView.frame;<br />
rect.size.height <span class="sy0">=</span> kScrollObjHeight;<br />
rect.size.width <span class="sy0">=</span> kScrollObjWidth;<br />
imageView.frame <span class="sy0">=</span> rect;<br />
imageView.tag <span class="sy0">=</span> i;<br />
<span class="br0">&#91;</span>scrollView1 addSubview<span class="sy0">:</span>imageView<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>imageView release<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="br0">&#91;</span>self layoutScrollImages<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#91;</span>scrollView2 setBackgroundColor<span class="sy0">:</span><span class="br0">&#91;</span>UIColor blackColor<span class="br0">&#93;</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>scrollView2 setCanCancelContentTouches<span class="sy0">:</span><span class="kw2">NO</span><span class="br0">&#93;</span>;<br />
scrollView2.clipsToBounds <span class="sy0">=</span> <span class="kw2">YES</span>;<br />
scrollView2.indicatorStyle <span class="sy0">=</span> UIScrollViewIndicatorStyleWhite;<br />
UIImageView <span class="sy0">*</span>imageView <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIImageView alloc<span class="br0">&#93;</span> initWithImage<span class="sy0">:</span><span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;image0.jpg&quot;</span><span class="br0">&#93;</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>scrollView2 addSubview<span class="sy0">:</span>imageView<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>scrollView2 setContentSize<span class="sy0">:</span>CGSizeMake<span class="br0">&#40;</span>imageView.frame.size.width, imageView.frame.size.height<span class="br0">&#41;</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>scrollView2 setScrollEnabled<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>imageView release<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 9:</strong> Compile and run the application in the simulator.<br />
<a href="http://edumobile.org/iphone/wp-content/uploads/2010/03/Simulator_scroll.jpg"><img class="alignnone size-medium wp-image-1174" title="Simulator_scroll" src="http://edumobile.org/iphone/wp-content/uploads/2010/03/Simulator_scroll-180x300.jpg" alt="" width="180" height="300" /></a></p>
<p>You can <strong>downloaded SourceCode</strong> from here  <a href='http://edumobile.org/iphone/wp-content/uploads/2010/03/Scroll-Image-2.zip'>Scroll Image 2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/impliment-scrolling-in-iphone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Implement a Custom Accessory View For UITableView in iPhone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/impliment-a-custom-accessory-view-for-your-uitableview-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/impliment-a-custom-accessory-view-for-your-uitableview-in-iphone/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 06:38:47 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[Custom Accessory with UITableView]]></category>
		<category><![CDATA[Implement a Custom Accessory View For UITableView in iPhone]]></category>
		<category><![CDATA[iphone development]]></category>

		<guid isPermaLink="false">http://edumobile.org/iphone/?p=1094</guid>
		<description><![CDATA[In this application we'll see how to implement a custom accessory view for your UITableView in the form of a checkmark button.]]></description>
			<content:encoded><![CDATA[<p>In this application we&#8217;ll see how to implement a custom accessory view for your UITableView in the form of a checkmark button.</p>
<p><strong>Step 1:</strong> Create a Window base application using template. Give the name of the application &#8220;CheckMark&#8221;.</p>
<p><strong>Step 2:</strong> Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.</p>
<p><strong>Step 3:</strong> We need to add the resource file called as “checked.png” and &#8220;unchecked.png&#8221; into the resource folder. Select resources and add files existing sources and select the checked.png and unchecked.png.</p>
<p><strong>Step 4:</strong> Now we’ll add Table view controller class to the project. Choose New file -&gt; Select cocoa touch classes group and then select UITableViewController subclass. Give the name TableView.</p>
<p><strong>Step 5:</strong> In the AppDelegate.h file, we define UINavigationController. Make the following changes in the AppDelegate.h file .</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="kw1">@interface</span> CheckMarkAppDelegate <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></p>
<p>UIWindow <span class="sy0">*</span>window;</p>
<p>UINavigationController <span class="sy0">*</span>myNavController;</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;</p>
<p><span class="kw1">@property</span> <span class="br0">&#40;</span>nonatomic, retain<span class="br0">&#41;</span> IBOutlet UINavigationController <span class="sy0">*</span>myNavController;</div>
</div>
<p><strong>Step 6:</strong> In the AppDelegate.m file , make the following changes :</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>applicationDidFinishLaunching<span class="sy0">:</span><span class="br0">&#40;</span>UIApplication <span class="sy0">*</span><span class="br0">&#41;</span>application <span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>window addSubview<span class="sy0">:</span> myNavController.view<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>window makeKeyAndVisible<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 7:</strong> We added dataArray in the TableView.h file, so make the following changes:</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="kw1">@interface</span> TableView <span class="sy0">:</span> UITableViewController <span class="br0">&#123;</span></p>
<p><span class="kw1">@private</span><br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span class="kw5">NSMutableArray</span></a> <span class="sy0">*</span>dataArray;</p>
<p><span class="br0">&#125;</span></div>
</div>
<p><strong>Step 8:</strong> Double click the MainWindow.xib file and open it to the Interface Builder. Drag Navigation Controller from the library and place it in the MainWindow. Double click Navigation Controller icon and open the Navigation Controller window. Change the title into &#8220;Add CheckMark&#8221;. Select View Controller and bring up identity inspector change the class name into TableView. Now drag table view from the library and place it to the Navigation Controller window. Select it and bring up connection inspector, you will see two connection are available dataSource and delegate. Drag dataSource to the table view . Do it once more time for the delegate. Save it and go back to the Xcode.</p>
<p><strong>Step 9:</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="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 />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>path <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> pathForResource<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;CheckMark&quot;</span> ofType<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;plist&quot;</span><span class="br0">&#93;</span>;<br />
self.dataArray <span class="sy0">=</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> arrayWithContentsOfFile<span class="sy0">:</span>path<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 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="br0">&#91;</span>dataArray count<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>tableView<span class="sy0">:</span><span class="br0">&#40;</span>UITableView <span class="sy0">*</span><span class="br0">&#41;</span>tableView &nbsp;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><br />
<span class="br0">&#91;</span>self tableView<span class="sy0">:</span> self.tableView &nbsp;accessoryButtonTappedForRowWithIndexPath<span class="sy0">:</span> indexPath<span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>self.tableView deselectRowAtIndexPath<span class="sy0">:</span>indexPath animated<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</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 &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 />
<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>kCustomCellID <span class="sy0">=</span> <span class="co3">@</span><span class="st0">&quot;MyCellID&quot;</span>;<br />
UITableViewCell <span class="sy0">*</span>cell <span class="sy0">=</span> <span class="br0">&#91;</span>tableView &nbsp; &nbsp;dequeueReusableCellWithIdentifier<span class="sy0">:</span>kCustomCellID<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><br />
<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> &nbsp;initWithStyle<span class="sy0">:</span>UITableViewCellStyleDefault reuseIdentifier<span class="sy0">:</span>kCustomCellID<span class="br0">&#93;</span> autorelease<span class="br0">&#93;</span>;<br />
cell.accessoryType <span class="sy0">=</span> UITableViewCellAccessoryDisclosureIndicator;<br />
cell.selectionStyle <span class="sy0">=</span> UITableViewCellSelectionStyleBlue;<br />
<span class="br0">&#125;</span></p>
<p><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/"><span class="kw5">NSMutableDictionary</span></a> <span class="sy0">*</span>item <span class="sy0">=</span> <span class="br0">&#91;</span>dataArray bjectAtIndex<span class="sy0">:</span>indexPath.row<span class="br0">&#93;</span>;<br />
cell.textLabel.text <span class="sy0">=</span> <span class="br0">&#91;</span>item objectForKey<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;text&quot;</span><span class="br0">&#93;</span>;</p>
<p><span class="br0">&#91;</span>item setObject<span class="sy0">:</span>cell forKey<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;cell&quot;</span><span class="br0">&#93;</span>;</p>
<p><span class="kw4">BOOL</span> checked <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>item objectForKey<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;checked&quot;</span><span class="br0">&#93;</span> boolValue<span class="br0">&#93;</span>;<br />
UIImage <span class="sy0">*</span>image <span class="sy0">=</span> <span class="br0">&#40;</span>checked<span class="br0">&#41;</span> ? <span class="br0">&#91;</span>UIImage &nbsp; imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;checked.png&quot;</span><span class="br0">&#93;</span> <span class="sy0">:</span> <span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;unchecked.png&quot;</span><span class="br0">&#93;</span>;</p>
<p>UIButton <span class="sy0">*</span>button <span class="sy0">=</span> <span class="br0">&#91;</span>UIButton buttonWithType<span class="sy0">:</span>UIButtonTypeCustom<span class="br0">&#93;</span>;<br />
CGRect frame <span class="sy0">=</span> CGRectMake<span class="br0">&#40;</span>0.0, 0.0, image.size.width, image.size.height<span class="br0">&#41;</span>;<br />
button.frame <span class="sy0">=</span> frame;<br />
<span class="br0">&#91;</span>button setBackgroundImage<span class="sy0">:</span>image forState<span class="sy0">:</span>UIControlStateNormal<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#91;</span>button addTarget<span class="sy0">:</span>self action<span class="sy0">:</span><span class="kw1">@selector</span><span class="br0">&#40;</span>checkButtonTapped<span class="sy0">:</span>event<span class="sy0">:</span><span class="br0">&#41;</span> &nbsp;forControlEvents<span class="sy0">:</span>UIControlEventTouchUpInside<span class="br0">&#93;</span>;<br />
button.backgroundColor <span class="sy0">=</span> <span class="br0">&#91;</span>UIColor clearColor<span class="br0">&#93;</span>;<br />
cell.accessoryView <span class="sy0">=</span> button;</p>
<p><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>checkButtonTapped<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender event<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>event<br />
<span class="br0">&#123;</span><br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span class="kw5">NSSet</span></a> <span class="sy0">*</span>touches <span class="sy0">=</span> <span class="br0">&#91;</span>event allTouches<span class="br0">&#93;</span>;<br />
UITouch <span class="sy0">*</span>touch <span class="sy0">=</span> <span class="br0">&#91;</span>touches anyObject<span class="br0">&#93;</span>;<br />
CGPoint currentTouchPosition <span class="sy0">=</span> <span class="br0">&#91;</span>touch locationInView<span class="sy0">:</span>self.tableView<span class="br0">&#93;</span>;<br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span class="kw5">NSIndexPath</span></a> <span class="sy0">*</span>indexPath <span class="sy0">=</span> <span class="br0">&#91;</span>self.tableView indexPathForRowAtPoint<span class="sy0">:</span> currentTouchPosition<span class="br0">&#93;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span>indexPath <span class="sy0">!=</span> <span class="kw2">nil</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="br0">&#91;</span>self tableView<span class="sy0">:</span> self.tableView accessoryButtonTappedForRowWithIndexPath<span class="sy0">:</span> indexPath<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><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 accessoryButtonTappedForRowWithIndexPath<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 />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/"><span class="kw5">NSMutableDictionary</span></a> <span class="sy0">*</span>item <span class="sy0">=</span> <span class="br0">&#91;</span>dataArray objectAtIndex<span class="sy0">:</span>indexPath.row<span class="br0">&#93;</span>;</p>
<p><span class="kw4">BOOL</span> checked <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>item objectForKey<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;checked&quot;</span><span class="br0">&#93;</span> boolValue<span class="br0">&#93;</span>;</p>
<p><span class="br0">&#91;</span>item setObject<span class="sy0">:</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/"><span class="kw5">NSNumber</span></a> numberWithBool<span class="sy0">:!</span>checked<span class="br0">&#93;</span> forKey<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;checked&quot;</span><span class="br0">&#93;</span>;</p>
<p>UITableViewCell <span class="sy0">*</span>cell <span class="sy0">=</span> <span class="br0">&#91;</span>item objectForKey<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;cell&quot;</span><span class="br0">&#93;</span>;<br />
UIButton <span class="sy0">*</span>button <span class="sy0">=</span> <span class="br0">&#40;</span>UIButton <span class="sy0">*</span><span class="br0">&#41;</span>cell.accessoryView;</p>
<p>UIImage <span class="sy0">*</span>newImage <span class="sy0">=</span> <span class="br0">&#40;</span>checked<span class="br0">&#41;</span> ? <span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;unchecked.png&quot;</span><span class="br0">&#93;</span> <span class="sy0">:</span> <span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;checked.png&quot;</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#91;</span>button setBackgroundImage<span class="sy0">:</span>newImage forState<span class="sy0">:</span>UIControlStateNormal<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong>Step 10:</strong> Compile and run the application in the Simulator.</p>
<p><a href="http://edumobile.org/iphone/wp-content/uploads/2010/03/table-view.jpg"><img class="alignnone size-medium wp-image-1102" title="table view" src="http://edumobile.org/iphone/wp-content/uploads/2010/03/table-view-184x300.jpg" alt="" width="184" height="300" /></a></p>
<p>You can <strong>downloaded SourceCod</strong>e from here  <a href='http://edumobile.org/iphone/wp-content/uploads/2010/03/CheckMark-2.zip'>CheckMark 2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/impliment-a-custom-accessory-view-for-your-uitableview-in-iphone/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Display Message in Iphone</title>
		<link>http://www.edumobile.org/iphone/iphone-programming-tutorials/display-message-in-iphone/</link>
		<comments>http://www.edumobile.org/iphone/iphone-programming-tutorials/display-message-in-iphone/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 11:43:14 +0000</pubDate>
		<dc:creator>Sushant</dc:creator>
				<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[Display Message]]></category>
		<category><![CDATA[Display Message in Iphone]]></category>
		<category><![CDATA[iphone development]]></category>

		<guid isPermaLink="false">http://edumobile.org/iphone/?p=796</guid>
		<description><![CDATA[Display message, its very easy to create. You just  type your firstname and lastname and click the button then message willl be display on your screen.]]></description>
			<content:encoded><![CDATA[<p>Display message, its very easy to create. You just  type your firstname and lastname and click the button then message willl be display on your screen.</p>
<p><strong><em>Step 1:</em></strong> Create a new project in Xcode using View base application.</p>
<p><strong><em>Step 2:</em></strong> Add some code in the header 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> HelloWorld1ViewController <span class="sy0">:</span> UIViewController <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; IBOutlet UITextField <span class="sy0">*</span>FirstName;<br />
&nbsp; &nbsp; &nbsp; &nbsp; IBOutlet UITextField <span class="sy0">*</span>LastName;<br />
&nbsp; &nbsp; &nbsp; &nbsp; IBOutlet UILabel <span class="sy0">*</span>lblMessage;<br />
<span class="br0">&#125;</span><br />
<span class="sy0">-</span> <span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span> Click<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">id</span><span class="br0">&#41;</span>sender;</div>
</div>
<p><strong><em>Step 3: </em></strong>Double click your .xib file and open it to Interface Builder. Click your View icon open the view window. Drag TextField  from the library and place it to view window. Then bring up attribute inspector, type &#8220;Enter your First Name&#8221;  in the placeholder. Do it once more time and  type &#8220;Enter Your Last Name&#8221;. Place Round Rect in the View window and give the name &#8220;Click&#8221;. Next drag Label from the library  and place it to view window. Now connect File&#8217;s Owner to the first TextField and select FirstName. Do it once more time and select LastName. Connect File&#8217;s Owner to the label and select ibiMessage. Select Round Rect and bring up connection inspector, drag TouchUpInside to File&#8217;s Owner and select Click: action. Now save your nib file and go back to the Xcode.</p>
<p><strong><em>Step 4: </em></strong>In the view base class, we mention a method Click:. When we press the click button it shows the message.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span> <span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span> Click<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; <br />
&nbsp;<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>firstName <span class="sy0">=</span> FirstName.text;<br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>lastName <span class="sy0">=</span> LastName.text;<br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span>Message <span class="sy0">=</span> <span class="kw2">nil</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="kw1">if</span><span class="br0">&#40;</span><span class="br0">&#91;</span>firstName length<span class="br0">&#93;</span> <span class="sy0">==</span> 0 <span class="sy0">&amp;&amp;</span> <span class="br0">&#91;</span>lastName length<span class="br0">&#93;</span> <span class="sy0">==</span> 0<span class="br0">&#41;</span><br />
Message <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> alloc<span class="br0">&#93;</span> initWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;Anonymous says Have A Nice Day!!!&quot;</span><span class="br0">&#93;</span>;<br />
<span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#91;</span>firstName length<span class="br0">&#93;</span> &gt; 0 <span class="sy0">&amp;&amp;</span> <span class="br0">&#91;</span>lastName length<span class="br0">&#93;</span> <span class="sy0">==</span>0<span class="br0">&#41;</span><br />
Message <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> alloc<span class="br0">&#93;</span> initWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;%@ says Have A Nice Day!!!&quot;</span>, firstName<span class="br0">&#93;</span>;<br />
<span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#91;</span>firstName length<span class="br0">&#93;</span> <span class="sy0">==</span> 0 <span class="sy0">&amp;&amp;</span> <span class="br0">&#91;</span>lastName length<span class="br0">&#93;</span> <span class="sy0">==</span> 0<span class="br0">&#41;</span><br />
Message <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> alloc<span class="br0">&#93;</span> initWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;%@ says Have A Nice Day!!!&quot;</span>, lastName<span class="br0">&#93;</span>;<br />
<span class="kw1">else</span><br />
&nbsp;Message <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> alloc<span class="br0">&#93;</span> initWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;%@ %@ says Have A Nice &nbsp;Day!!!&quot;</span>, firstName, lastName<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
lblMessage.text <span class="sy0">=</span> Message;</p>
<p><span class="br0">&#91;</span>Message 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">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>theTextField <span class="br0">&#123;</span><br />
&nbsp; <span class="br0">&#91;</span>theTextField resignFirstResponder<span class="br0">&#93;</span>;<br />
&nbsp; <span class="kw1">return</span> <span class="kw2">YES</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><strong><em>Step 5:</em></strong> Now compile your application and run on the Simulator.(see figure 1)<br />
<a href="http://edumobile.org/iphone/wp-content/uploads/2010/02/Dispaly1.jpg"><img src="http://edumobile.org/iphone/wp-content/uploads/2010/02/Dispaly1-154x300.jpg" alt="" title="Dispaly" width="154" height="300" class="alignnone size-medium wp-image-804" /></a></p>
<p><strong><em>Figure 1: Message Display.</em></strong></p>
<p>You can <strong>downloaded SourceCode</strong> from here  <a href='http://edumobile.org/iphone/wp-content/uploads/2010/02/HelloWorld1-2.zip'>HelloWorld1 2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edumobile.org/iphone/iphone-programming-tutorials/display-message-in-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

