<?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>Notes of a Developer &#187; UIPopoverController</title>
	<atom:link href="http://www.developers-life.com/tag/uipopovercontroller/feed" rel="self" type="application/rss+xml" />
	<link>http://www.developers-life.com</link>
	<description>Develop on Objective-C, UIKit, C, OpenGL for  iPhone, iPad, Mac OS X</description>
	<lastBuildDate>Sun, 05 Sep 2010 16:29:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Samples code for iPad development from apple</title>
		<link>http://www.developers-life.com/samples-code-for-ipad-development-from-apple.html</link>
		<comments>http://www.developers-life.com/samples-code-for-ipad-development-from-apple.html#comments</comments>
		<pubDate>Fri, 29 Jan 2010 12:29:26 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[UIGestureRecognizer]]></category>
		<category><![CDATA[UIKit]]></category>
		<category><![CDATA[UIPopoverController]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=837</guid>
		<description><![CDATA[ToolbarSearch
This sample shows how to use a search field in a toolbar. When you start a search, a table view displaying recent searches matching the current search string is displayed in a popover. 
New controller:
UIPopoverControllerDelegate


Create a navigation controller to contain the recent searches controller, and create the popover controller to contain the navigation controller.
UINavigationController *navigationController [...]]]></description>
			<content:encoded><![CDATA[<h4>ToolbarSearch</h4>
<p>This sample shows how to use a search field in a toolbar. When you start a search, a table view displaying recent searches matching the current search string is displayed in a popover. </p>
<p>New controller:</p>
<div class="codecolorer-container objc" style="height:35px;"><div class="objc codecolorer"><ol><li class="li1"><div class="de1">UIPopoverControllerDelegate</div></li>
</ol></div></div>
<p><a href="http://gyazo.com/66595120efa983da5d02f7a4a5994e1c.png"><img class="alignnone" src="http://gyazo.com/66595120efa983da5d02f7a4a5994e1c.png" alt="" width="243" height="315" /></a></p>
<p>Create a navigation controller to contain the recent searches controller, and create the popover controller to contain the navigation controller.</p>
<div class="codecolorer-container objc"><div class="objc codecolorer"><ol><li class="li1"><div class="de1">UINavigationController <span class="sy0">*</span>navigationController <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UINavigationController alloc<span class="br0">&#93;</span> initWithRootViewController<span class="sy0">:</span>recentSearchesController<span class="br0">&#93;</span>;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; UIPopoverController <span class="sy0">*</span>popover <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIPopoverController alloc<span class="br0">&#93;</span> initWithContentViewController<span class="sy0">:</span>navigationController<span class="br0">&#93;</span>;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; self.recentSearchesPopoverController <span class="sy0">=</span> popover;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; recentSearchesPopoverController.delegate <span class="sy0">=</span> self;</div></li>
</ol></div></div>
<p><span id="more-837"></span></p>
<p>delegate methods of UIPopoverControllerDelegate</p>
<div class="codecolorer-container objc"><div class="objc codecolorer"><ol><li class="li1"><div class="de1"><span class="coMULTI">/* Called on the delegate when the popover controller will dismiss the popover. Return NO to prevent the dismissal of the view.</span></div></li>
<li class="li1"><div class="de1"><span class="coMULTI">&nbsp;*/</span></div></li>
<li class="li1"><div class="de1"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>popoverControllerShouldDismissPopover<span class="sy0">:</span><span class="br0">&#40;</span>UIPopoverController <span class="sy0">*</span><span class="br0">&#41;</span>popoverController;</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="coMULTI">/* Called on the delegate when the user has taken action to dismiss the popover. This is not called when -dismissAnimated: is called directly.</span></div></li>
<li class="li1"><div class="de1"><span class="coMULTI">&nbsp;*/</span></div></li>
<li class="li1"><div class="de1"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>popoverControllerDidDismissPopover<span class="sy0">:</span><span class="br0">&#40;</span>UIPopoverController <span class="sy0">*</span><span class="br0">&#41;</span>popoverController;</div></li>
</ol></div></div>
<p>&nbsp;</p>
<h4>KeyboardAccessory</h4>
<p>This sample shows how to use a keyboard accessory view.<br />
 You can create the accessory view programmatically (in code), in the same nib file as the view controller&#8217;s main view, or from a separate nib file. This example illustrates the latter; it means the accessory view is loaded lazily &#8212; only if it is required.</p>
<div class="codecolorer-container objc"><div class="objc codecolorer"><ol><li class="li1"><div class="de1"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>textViewShouldBeginEditing<span class="sy0">:</span><span class="br0">&#40;</span>UITextView <span class="sy0">*</span><span class="br0">&#41;</span>aTextView <span class="br0">&#123;</span> &nbsp; &nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span><span class="br0">&#91;</span><span class="kw5">NSBundle</span> mainBundle<span class="br0">&#93;</span> loadNibNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;AccessoryView&quot;</span> owner<span class="sy0">:</span>self options<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="co2">// Loading the AccessoryView nib file sets the accessoryView outlet.</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; textView.inputAccessoryView <span class="sy0">=</span> accessoryView; &nbsp; &nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="co2">// After setting the accessory view for the text view, we no longer need a reference to the accessory view.</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; self.accessoryView <span class="sy0">=</span> <span class="kw2">nil</span>;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">YES</span>;</div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></div>
<p><img class="aligncenter" src="http://gyazo.com/cd1a224fb78d0ce9016beb18c59a829c.png" alt="" width="485" height="83" /></p>
<p><a href="http://gyazo.com/f906dcf5e949ad544a0b034ef049d219.png">We will get this result</a></p>
<p>&nbsp;</p>
<h4>SimpleGestureRecognizers</h4>
<p>This sample shows how to use standard gesture recognizers.<br />
A view controller creates four gesture recognizers to recognize a tap, a right swipe, a left swipe, and a rotation gesture. When they recognize a gesture, the recognizers send a suitable message to the view controller, which in turn displays an appropriate image at the location of the gesture.</p>
<p>New delegate</p>
<div class="codecolorer-container objc" style="height:35px;"><div class="objc codecolorer"><ol><li class="li1"><div class="de1">UIGestureRecognizerDelegate</div></li>
</ol></div></div>
<p>Create a rotation gesture recognizer, similar  create a swipe gesture recognizer to recognize right swipes (the default).<br />
 We&#8217;re only interested in receiving messages from this recognizer, and the view will take ownership of it, so we don&#8217;t need to keep a reference to it.</p>
<div class="codecolorer-container objc"><div class="objc codecolorer"><ol><li class="li1"><div class="de1">recognizer <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIRotationGestureRecognizer alloc<span class="br0">&#93;</span> initWithTarget<span class="sy0">:</span>self action<span class="sy0">:</span><span class="kw1">@selector</span><span class="br0">&#40;</span>handleRotationFrom<span class="sy0">:</span><span class="br0">&#41;</span><span class="br0">&#93;</span>;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span>self.view addGestureRecognizer<span class="sy0">:</span>recognizer<span class="br0">&#93;</span>;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span>recognizer release<span class="br0">&#93;</span>;</div></li>
</ol></div></div>
<p>Create a tap recognizer and add it to the view.<br />
     Keep a reference to the recognizer to test in gestureRecognizer:shouldReceiveTouch:.</p>
<div class="codecolorer-container objc"><div class="objc codecolorer"><ol><li class="li1"><div class="de1">recognizer <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UITapGestureRecognizer alloc<span class="br0">&#93;</span> initWithTarget<span class="sy0">:</span>self action<span class="sy0">:</span><span class="kw1">@selector</span><span class="br0">&#40;</span>handleTapFrom<span class="sy0">:</span><span class="br0">&#41;</span><span class="br0">&#93;</span>;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span>self.view addGestureRecognizer<span class="sy0">:</span>recognizer<span class="br0">&#93;</span>;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; self.tapRecognizer <span class="sy0">=</span> <span class="br0">&#40;</span>UITapGestureRecognizer <span class="sy0">*</span><span class="br0">&#41;</span>recognizer;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; recognizer.delegate <span class="sy0">=</span> self;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span>recognizer release<span class="br0">&#93;</span>;</div></li>
</ol></div></div>
<p>Get direction in handle method:</p>
<div class="codecolorer-container objc"><div class="objc codecolorer"><ol><li class="li1"><div class="de1"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>handleSwipeFrom<span class="sy0">:</span><span class="br0">&#40;</span>UISwipeGestureRecognizer <span class="sy0">*</span><span class="br0">&#41;</span>recognizer <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>recognizer.direction <span class="sy0">==</span> UISwipeGestureRecognizerDirectionLeft<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></div>
<p>In UKit.framework we have few new objects for this:<br />
<a href="http://gyazo.com/b6614f4b29d0d969af6ee613dffe122f.png"><img alt="" src="http://gyazo.com/b6614f4b29d0d969af6ee613dffe122f.png" class="alignnone" width="254" height="138" /></a></p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/t3a1AVoCO5w&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/t3a1AVoCO5w&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>Source: <noindex><a href="http://developer.apple.com" target="_blank">developer.apple.com</a></noindex></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/samples-code-for-ipad-development-from-apple.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
