<?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>noizZze &#187; iPhone</title>
	<atom:link href="http://blog.noizeramp.com/category/programming/iphone/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.noizeramp.com</link>
	<description>Am I a finished product -- or a work in progress?</description>
	<lastBuildDate>Wed, 01 Sep 2010 11:34:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iPhone: Black navigation bar in &#8220;More&#8230;&#8221; view</title>
		<link>http://blog.noizeramp.com/2009/08/06/iphone-black-navigation-bar-in-more-view/</link>
		<comments>http://blog.noizeramp.com/2009/08/06/iphone-black-navigation-bar-in-more-view/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 07:41:30 +0000</pubDate>
		<dc:creator>Aleksey Gureiev</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[uinavigationcontroller]]></category>
		<category><![CDATA[uitabbarcontroller]]></category>

		<guid isPermaLink="false">http://blog.noizeramp.com/?p=615</guid>
		<description><![CDATA[On iPhone, there&#8217;s the tab bar control that we, developers, can use to switch between several pages. It appears as a black stripe with icons at the bottom of the screen. Probably, the most famous is the tab bar of the Clock application:

It can show up to 5 icons and if there&#8217;s not enough space [...]]]></description>
			<content:encoded><![CDATA[<p>On iPhone, there&#8217;s the tab bar control that we, developers, can use to switch between several pages. It appears as a black stripe with icons at the bottom of the screen. Probably, the most famous is the tab bar of the Clock application:</p>
<p style="text-align: center; "><img class="size-full wp-image-616 aligncenter" title="Clock tab bar" src="http://blog.noizeramp.com/wp-content/uploads/2009/08/skitched-20090806-101909.jpg" alt="Clock tab bar" width="195" height="29" /></p>
<p>It can show up to 5 icons and if there&#8217;s not enough space left, the last one is replaced with the &#8220;More &#8230;&#8221; item. When clicked, it shows the nice view with the list of all available options that didn&#8217;t fit into the tab bar. <em>UITabBarController</em> delegates the job to the <em>UINavigationController</em>. Now why I tell all this?</p>
<p>By default, the <em>UINavigationController</em> uses that standard blue top bar, but what if I want it to be Black as in the rest of my app?</p>
<p>First, let&#8217;s change the style of the &#8220;More &#8230;&#8221; page top bar. It&#8217;s all pretty straight forward as you can see. Just get the navigation controller and set the style of its bar:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">tabBarController.moreNavigationController.navigationBar.barStyle <span style="color: #002200;">=</span> UIBarStyleBlack;</div></div>
<p>Finally, let&#8217;s change the style of the bar on the &#8220;More &#8230;&#8221; / Edit page (that says &#8220;Configure&#8221; by the way). It appears that you can&#8217;t drill down into the object model like above, but have to catch the moment when the editor is about to come out and do the magic. For this to happen, you needthe tab bar delegate (<em>UITabBarControllerDelegate</em> protocol) and use the <em>tabBarController:willBeginCustomizingViewControllers:</em> callback to nail it:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">tabBarController.delegate <span style="color: #002200;">=</span> self;</div></div>
<p>and later:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>tabBarController<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITabBarController <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tabBarController<br />
&nbsp; &nbsp; &nbsp; &nbsp; willBeginCustomizingViewControllers<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>viewControllers <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; UIView <span style="color: #002200;">*</span>views <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>tabBarController.view.subviews objectAtIndex<span style="color: #002200;">:</span>1<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; UINavigationBar <span style="color: #002200;">*</span>navBar <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>views subviews<span style="color: #002200;">&#93;</span> objectAtIndex<span style="color: #002200;">:</span>0<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; navBar.barStyle <span style="color: #002200;">=</span> UIBarStyleBlack;<br />
<span style="color: #002200;">&#125;</span></div></div>
<p>In the above 3-liner, you can see that we do the trick to actually find the navigation bar. It works nicely on iPhone 3.0, but may change in the future, so be careful.</p>
<p>Don&#8217;t forget that you can always subclass <em>UITabBarController</em> and hide all this customization logic inside to stay on the clean design side. In my work, I do that and used the <em>tabBarController</em> here to clearly state what model we operate on.</p>
<p>That&#8217;s all, folks. Hope it helped someone to save a couple of hours.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.noizeramp.com/2009/08/06/iphone-black-navigation-bar-in-more-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone: Background Lookup and Dictionaries</title>
		<link>http://blog.noizeramp.com/2009/06/01/iphone-background-lookup-and-dictionaries/</link>
		<comments>http://blog.noizeramp.com/2009/06/01/iphone-background-lookup-and-dictionaries/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 18:22:35 +0000</pubDate>
		<dc:creator>Aleksey Gureiev</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[dictionary]]></category>
		<category><![CDATA[lookup]]></category>

		<guid isPermaLink="false">http://blog.noizeramp.com/?p=533</guid>
		<description><![CDATA[First of all, for those who don&#8217;t follow me on twitter (@spyromus), this year I&#8217;m working on my Cocoa / Cocoa Touch skills. Love it immensely so far and especially how things are nicely done in the iPhone department. A sheer pleasure.
During the last few weeks I tried several iPhone dictionaries and surprisingly all of [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, for those who don&#8217;t follow me on twitter (<a href="http://twitter.com/spyromus">@spyromus</a>), this year I&#8217;m working on my Cocoa / Cocoa Touch skills. Love it immensely so far and especially how things are nicely done in the iPhone department. A sheer pleasure.</p>
<p>During the last few weeks I tried several iPhone dictionaries and surprisingly all of them ( I mean ALL ) are coded in a strange way. The one of the most important parts &#8212; word entry &#8212; is implemented in a totally unimaginative straightforward way where it either looks up whatever you enter against their huge databases after every new letter or does that periodically. Both versions block the search box every now and then and don&#8217;t let you enter your searches quickly.</p>
<p>No finger pointing here certainly, but you guys know who you are. I tried to contact authors and share this bit of knowledge, but it&#8217;s either http://localhost/ as the support link or no link at all, so&#8230; the least I can do is to share it here. Hope it&#8217;ll be of some help.</p>
<p>Here&#8217;s the part of a <em>XYZViewController</em>:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>viewDidLoad <span style="color: #002200;">&#123;</span><br />
&nbsp; operationQueue <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSOperationQueue</span> new<span style="color: #002200;">&#93;</span>;<br />
&nbsp; <span style="color: #002200;">&#91;</span>super viewDidLoad<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>searchBar<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UISearchBar <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>searchBar<br />
&nbsp; &nbsp; textDidChange<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>searchText <span style="color: #002200;">&#123;</span><br />
&nbsp; <span style="color: #002200;">&#91;</span>operationQueue cancelAllOperations<span style="color: #002200;">&#93;</span>;<br />
<br />
&nbsp; SearchOperation <span style="color: #002200;">*</span>op <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>SearchOperation alloc<span style="color: #002200;">&#93;</span> <br />
&nbsp; &nbsp; initWithText<span style="color: #002200;">:</span>searchText dictionary<span style="color: #002200;">:</span>dictionary controller<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;<br />
<br />
&nbsp; <span style="color: #002200;">&#91;</span>operationQueue addOperation<span style="color: #002200;">:</span>op<span style="color: #002200;">&#93;</span>;<br />
&nbsp; <span style="color: #002200;">&#91;</span>op release<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span></div></div>
<p>Where <em>SearchOperation</em> is a subclass of <em>NSOperation</em> and its main method looks something like this:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> main <span style="color: #002200;">&#123;</span><br />
&nbsp; <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSThread</span> sleepForTimeInterval<span style="color: #002200;">:</span> 0.25f<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span><span style="color: #002200;">&#91;</span>self isCancelled<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// Do your searching magic here ...</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>controller performSelectorOnMainThread<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>searchResult<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; withObject<span style="color: #002200;">:</span>...<br />
&nbsp; &nbsp; &nbsp; waitUntilDone<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; <span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span></div></div>
<p>The idea is that when the user types a letter, the <em>searchBar:textDidChange:</em> is called, but it doesn&#8217;t do the search right away. Instead it creates an instance of the <em>SearchOperation</em> which represents a lengthy dictionary lookup and queues it. Each <em>SearchOperation</em> sleeps 1/4 seconds before it starts doing any work. In fact, before the actual start it checks if it was canceled and does that periodically during the search. </p>
<p>So when it can be canceled? That&#8217;s why we have the <em>cancelAllOperations</em> call in the queuing code. If the user types, every next letter results in the cancellation of previous search operations and none of them will complete or even start. Moreover, the user interface will never be blocked and your users can type away freely and only if they stop, the GUI will follow and show the results.</p>
<p>You see? Simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.noizeramp.com/2009/06/01/iphone-background-lookup-and-dictionaries/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
