<?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>D17's blog &#187; form</title>
	<atom:link href="http://blog.d-17.com/tag/form/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.d-17.com</link>
	<description>About hardcore technology and softcore business</description>
	<lastBuildDate>Wed, 13 Oct 2010 09:54:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Combining multiple UITextFields and a UITableView in a nice way for an iPhone app: part 2</title>
		<link>http://blog.d-17.com/2009/10/combining-multiple-uitextfields-and-a-uitableview-in-a-nice-way-for-an-iphone-app-part-2/</link>
		<comments>http://blog.d-17.com/2009/10/combining-multiple-uitextfields-and-a-uitableview-in-a-nice-way-for-an-iphone-app-part-2/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 16:19:21 +0000</pubDate>
		<dc:creator>Dirk de Kok</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[UITableView]]></category>

		<guid isPermaLink="false">http://blog.d-17.com/?p=118</guid>
		<description><![CDATA[My last blog post was about creating a form for an iPhone application by combining multiple UITextFields in a UITableView. I outlined the problems with this kind of screens. The first problem is the destruction of data already entered when scrolling the field off screen and secondly, app crashes when the field with focus is [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="/2009/08/combining-multiple-uitextfields-and-a-uitableview-in-a-nice-way-for-an-iphone-app/"> last blog post</a> was about creating a form for an iPhone application by combining multiple UITextFields in a UITableView. I outlined the problems with this kind of screens. The first problem is the destruction of data already entered when scrolling the field off screen and secondly, app crashes when the field with focus is scrolled off screen and you touch inside another textfield. The solution I proposed was to nest the UITableView inside a UIScrollview. After receiving feedback I came up with a second solution:</p>
<ol>
<li>extend a UITableViewController instead of implementing UITableviewDataSource and UITableViewDelegate yourself</li>
<li>disable reuse of cells by using a unique cell identifier:</li>
<p style="font: normal normal normal 10px/normal Monaco; text-align: left; margin: 0px;"><span style="color: #5c2699;">NSString</span> *CellIdentifier = [<span style="color: #5c2699;">NSString</span> <span style="color: #2e0d6e;">stringWithFormat</span>: <span style="color: #c41a16;">@"Cell%i"</span>, indexPath.<span style="color: #2e0d6e;">row</span>];</p>
<p style="font: normal normal normal 10px/normal Monaco; text-align: left; margin: 0px;"><span style="color: #5c2699;">UITableViewCell</span> *cell = [tableView <span style="color: #2e0d6e;">dequeueReusableCellWithIdentifier</span>:CellIdentifier];</p>
<p style="font: normal normal normal 10px/normal Monaco; text-align: left; margin: 0px;"><span style="color: #aa0d91;">if</span> (cell == <span style="color: #aa0d91;">nil</span>) {</p>
<p style="font: normal normal normal 10px/normal Monaco; color: #2e0d6e; text-align: left; margin: 0px;margin-left:15px"><span style="color: #000000;"> cell = [[</span><span style="color: #5c2699;">UITableViewCell</span><span style="color: #000000;"> </span>alloc<span style="color: #000000;">] </span>initWithStyle<span style="color: #000000;">:</span>UITableViewCellStyleDefault<span style="color: #000000;"> </span>reuseIdentifier<span style="color: #000000;">:CellIdentifier];</span></p>
<p style="font: normal normal normal 10px/normal Monaco; color: #2e0d6e; text-align: left; margin: 0px;margin-left:15px"><span style="color: #000000;"> ..</span></p>
<p style="font: normal normal normal 10px/normal Monaco; color: #2e0d6e; text-align: left; margin: 0px;"><span style="color: #000000;">}</span></p>
</ol>
<p>The UITableViewController handles scrolling into view when the keyboard is shown quite nicely. Using the unique identifier will prevent a cell and it&#8217;s content to be reused. And I had to agree to some of the feedback: using a UIScrollView to nest a tableView is kind of a hack.</p>
<p>There is a down side to this: UITableViewControllers don&#8217;t like to be combined with other view controllers, so you have to use a NavigationController or TabBarController to offer further interaction possibilities. I tried to, but never managed nicely to have for instance a UIToolBar over the UITableView.</p>
<p>Try it out and let me know what you think!</p>
<p>Download XCode project <a href="http://blog.d-17.com/wp-content/uploads/2009/10/TestTableViewWithKeyboard2.zip">TestTableViewWithKeyboard2</a> with demo using UITableView to create a form.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.d-17.com/2009/10/combining-multiple-uitextfields-and-a-uitableview-in-a-nice-way-for-an-iphone-app-part-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

