<?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>MetaMurph &#187; iphone-sdk</title>
	<atom:link href="http://seanmurph.com/weblog/tag/iphone-sdk/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanmurph.com/weblog</link>
	<description>Writing about Cocoa and iPhone Development</description>
	<lastBuildDate>Sat, 13 Mar 2010 16:49:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Designing the most elegant, usable iPhone table view search</title>
		<link>http://seanmurph.com/weblog/designing-the-most-elegant-iphone-table-view-search/</link>
		<comments>http://seanmurph.com/weblog/designing-the-most-elegant-iphone-table-view-search/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 18:43:39 +0000</pubDate>
		<dc:creator>Sean Murphy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iphone-sdk]]></category>

		<guid isPermaLink="false">http://seanmurph.com/weblog/?p=34</guid>
		<description><![CDATA[When it came to adding a search feature to my iPhone application Harvest, I ended up choosing not to follow the usual (Apple exemplified) approach of placing a search bar above a table view and scrolling it with the content. This post explains this and other design decisions I made, even to the smallest detail, [...]]]></description>
			<content:encoded><![CDATA[<div class="pre-post-summary">
<p>When it came to adding a search feature to my iPhone application <a href="http://harvest-app.com">Harvest</a>, I ended up choosing not to follow the usual (Apple exemplified) approach of placing a search bar above a table view and scrolling it with the content.  This post explains this and other design decisions I made, even to the smallest detail, as I strived to create the most usable and polished search feature.</p>
</div>
<p>Providing a mechanism to search among a table view of items is a common element present in so many iPhone applications, in fact it&#8217;s almost unexpected to see a list of items without a way to filter through them.  Even though the feature is generally the same across all of these applications, I feel it can be refined and highly polished through many seemingly minor details.  I&#8217;d like to explain some of the characteristics which I put considerable thought into when designing Harvest&#8217;s search, ones I believe contribute significantly to the usability of the application.</p>
<p><span id="more-34"></span></p>
<h3>One press away from a focused search field</h3>
<p>As I mentioned above, I chose to deviate from the common search UI pattern of throwing a search bar on top of a table view, and scrolling it with the content as if it&#8217;s the first row.  In many other applications, most significantly Apple&#8217;s own Contacts and iPod apps for instance, this is the approach.</p>
<p>I designed Harvest&#8217;s produce guide so that a focused search field, with the keyboard displayed and ready for input, will always be only one touch away.  After all, if a user is searching, they want to find an item quickly.</p>
<div class="photo">
<img class="alignleft size-full wp-image-39" title="Searching in Harvest" src="http://seanmurph.com/weblog/wp-content/uploads/search-feature/Harvest-before-searching.jpg" alt="Searching in Harvest" />&nbsp;<img class="alignleft size-full wp-image-39" src="http://seanmurph.com/weblog/wp-content/uploads/search-feature/Harvest-focused-search.jpg" alt="Focused search bar in Harvest" /></p>
<p>Pressing the search icon, in the top right, from anywhere in the guide slides in a search bar and focuses the keyboard, all with one touch.</p>
</div>
<p>With the scrolling search bar approach, it becomes necessary to scroll all the way to the first row before touching again inside the search bar to start entering a query.  Additionally, often times I&#8217;ve found myself having to tap multiple times to get the search field to focus, possibly because the scroll action was still causing the table content to bounce at the top boundary when I pressed the first time.</p>
<p>Even if the user is aware of the global iPhone shortcut of touching the status bar to scroll to the top, which I&#8217;m guessing many aren&#8217;t, it&#8217;s still a matter of two touches.  With over 60 produce items in Harvest, I knew it is very more likely that the user will be somewhere other than at the top of the content.</p>
<p>Another consequence of scrolling the search bar is that when it moves out of view, there is no current on screen indication of the feature&#8217;s availability.  Search is crucial in Harvest&#8217;s produce guide, and it is likely the standard way in which users will find themselves referencing items during daily use.  I wanted it to always be evident that the feature exists and is readily available.</p>
<div class="photo">
<img class="alignleft size-full wp-image-39"src="http://seanmurph.com/weblog/wp-content/uploads/search-feature/iPod-searching-top.jpg" alt="iPod Searching" />&nbsp;<img class="alignleft size-full wp-image-39"src="http://seanmurph.com/weblog/wp-content/uploads/search-feature/iPod-searching-bottom.jpg" alt="iPod Searching" /><br/></p>
<p>With a scrolling search bar, unless you are at the top of the table&#8217;s content, there is no search feature visible and accessible with one touch.
</p>
</div>
<p>Having search always visible encourages the user to use it.  Scrolling it offscreen makes it seem like a secondary, less important way to reference items.  Leaving it visible at all times was my way of encouraging users to search, and in doing so I knew they&#8217;d find Harvest more practical to use frequently with every item they&#8217;re shopping for, making the overall experience in my application more satisfactory.</p>
<p>There&#8217;s nothing inherently incorrect about the scrolling search bar design, I just didn&#8217;t feel it was best for Harvest.  The huge advantage of the approach is that saves screen real estate, while at the same time avoids requiring any further UI elements to access the search, such as a navigation button; you just scroll upwards.</p>
<p>I took advantage of the fact that I had a free right navigation bar button spot available.  Offering a spotlight-like search button there, I was able to balance ease of access and feature visibility with screen real estate.  I did not have to resort to taking away 44 points from the produce guide table view&#8217;s height, permanently displaying a search bar above the table view without scrolling it away, to achieve my design goals.</p>
<h3>See all results without hiding the keyboard</h3>
<p>Another portrayal of attention to detail when it comes to searching is to ensure that all results can be seen without dismissing the keyboard.  By this I mean resizing the results table view when the keyboard is visible so that the user can scroll all the way to the bottom of the content (i.e. the last row appearing directly above the keyboard).</p>
<p>I&#8217;ve come across some applications in which the search results table view dimensions remained at the full-screen height even when the keyboard is displayed, so that the only way to see the bottom half of the table content was to dismiss the keyboard.</p>
<div class="photo">
<img class="alignleft size-full wp-image-39"src="http://seanmurph.com/weblog/wp-content/uploads/search-feature/Resized-results-table.jpg" alt="Resized Results Table View" /><br/></p>
<p class="single-image">All search results should be accessible without having to dismiss the keyboard</p>
</div>
<p>Allowing the user to see all of the results enables them to further refine their search without having to call up the keyboard to do so.</p>
<h3>Polish in the tiny details: The keyboard return key</h3>
<p>I see two different modes of searching on the iPhone.  The one used in Harvest, Contacts, and iPod, is actually better phrased as filtering.  This mode shows results immediately, live as the user is entering or modifying the search query.  The other mode of searching involves results that are not delivered immediately, but rather are obtained from a server after the query is sent out over a network connection.  This latter approach is what you see in the App Store app.</p>
<p>Despite these two different modes, the keyboard displayed from a search bar always presents a return key labeled &#8220;Search.&#8221;  When the search mode is a live filter, and results are already available, I view this button label as imprecise.  There is no further searching action that will take place when pressing it, and button label verbs indicate that such an action will be performed when pressed.  In a live filter, the search has already taken place and pressing search merely hides the keyboard, so the current results can be seen more visibly.</p>
<div class="photo">
<img class="alignleft size-full wp-image-39"src="http://seanmurph.com/weblog/wp-content/uploads/search-feature/iPod-searching.jpg" alt="iPod Return Key" />&nbsp;<img class="alignleft size-full wp-image-39"src="http://seanmurph.com/weblog/wp-content/uploads/search-feature/Harvest-return-key" alt="Harvest Return Key" /><br/></p>
<p>iPod and Harvest keyboard return buttons when searching (bottom right, in blue).  In both apps, the search results are available instantly, making a button labeled &#8220;Search&#8221; seem odd.</p>
</div>
<p>Therefore, I aimed to relabel the button to better indicate the fact that pressing it will actually just get the keyboard out of the way.  The &#8220;Done&#8221; key thus makes much more sense to me.  The results are already there, so pressing &#8220;search&#8221; always felt backwards to me.</p>
<p>There&#8217;s no official supported way to customize the UIReturnKeyType of the search bar&#8217;s keyboard.  The following block of code is my way of safely accomplishing this customization:</p>
<div class="code-snippet">
<h3 class="code-file">Changing the UISearchBar keyboard&#8217;s return key</h3>
<pre class="textmate-source lazy"><span class="source source_objc"><span class="keyword keyword_control keyword_control_c">for</span> (UIView *searchBarSubview in <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_begin punctuation_section_scope_begin_objc">[</span>searchBar <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">subviews</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_end punctuation_section_scope_end_objc">]</span></span>) <span class="meta meta_block meta_block_c">{
  <span class="keyword keyword_control keyword_control_c">if</span><span class="meta meta_initialization meta_initialization_c"> <span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_c">(</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_begin punctuation_section_scope_begin_objc">[</span>searchBarSubview <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">conformsToProtocol<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="storage storage_type storage_type_objc"><span class="punctuation punctuation_definition punctuation_definition_storage punctuation_definition_storage_type punctuation_definition_storage_type_objc">@</span>protocol</span>(UITextInputTraits)</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_end punctuation_section_scope_end_objc">]</span></span>) <span class="meta meta_block meta_block_c">{
    <span class="keyword keyword_control keyword_control_exception keyword_control_exception_objc"><span class="punctuation punctuation_definition punctuation_definition_keyword punctuation_definition_keyword_objc">@</span>try</span> <span class="meta meta_block meta_block_c">{
      <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_begin punctuation_section_scope_begin_objc">[</span>(UITextField *)searchBarSubview <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">setReturnKeyType<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>UIReturnKeyDone</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_end punctuation_section_scope_end_objc">]</span></span>;
    }</span>
    <span class="keyword keyword_control keyword_control_exception keyword_control_exception_objc"><span class="punctuation punctuation_definition punctuation_definition_keyword punctuation_definition_keyword_objc">@</span>catch</span><span class="meta meta_initialization meta_initialization_c"> <span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_c">(</span></span><span class="support support_class support_class_cocoa">NSException</span> * e) <span class="meta meta_block meta_block_c">{
      <span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span> ignore exception
</span>    }</span>
  }</span>
}</span></span></pre>
</div>
<p>In the server-based search mode, the button labeled as &#8220;Search&#8221; does fit the behavior perfectly.</p>
<h3>Conclusion</h3>
<p>Through this writing, I wanted to demonstrate the attentiveness to detail that I strived to put into Harvest.  One of the reasons I love developing for the iPhone and Mac platforms is that attention to detail is noticed, and even expected, by the users themselves.  The best usability is expressed both in more obvious features, such as a persistently visible search, and minor ones as well such as resizing the results table view or changing a button label to better reflect its action.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanmurph.com/weblog/designing-the-most-elegant-iphone-table-view-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

