<?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.mitchallen.com &#187; headers</title>
	<atom:link href="http://mitchallen.com/iphone/archives/tag/headers/feed" rel="self" type="application/rss+xml" />
	<link>http://mitchallen.com/iphone</link>
	<description>random notes on iPhone development</description>
	<lastBuildDate>Tue, 10 Aug 2010 20:36:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Adding Headers and Footers to Table Views</title>
		<link>http://mitchallen.com/iphone/archives/172</link>
		<comments>http://mitchallen.com/iphone/archives/172#comments</comments>
		<pubDate>Mon, 25 May 2009 23:15:47 +0000</pubDate>
		<dc:creator>Mitch  Allen</dc:creator>
				<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[footers]]></category>
		<category><![CDATA[headers]]></category>
		<category><![CDATA[tables]]></category>
		<category><![CDATA[UITableViewController]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://mitchallen.com/iphone/?p=172</guid>
		<description><![CDATA[Here is an easy way to create headers and footers for iPhone Table Views. In your Xcode project right-click on the Resources folder Select: Add / New File &#8230; / iPhone OS / User Interfaces / View XIB / [Next] Call it HeaderView.xib and click Finish GIve the View a unique background color and set [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an easy way to create headers and footers for iPhone Table Views.</p>
<ol>
<li>In your Xcode project right-click on the <strong>Resources</strong> folder</li>
<li>Select: <strong>Add / New File &#8230; / iPhone OS / User Interfaces / View XIB / [Next]</strong></li>
<li>Call it <strong><em>HeaderView.xib</em></strong> and click <strong>Finish</strong></li>
<li>GIve the View a unique background color and set the height to 44</li>
<li>Repeat for <strong>FooterView.xib</strong></li>
<li>Save both files</li>
</ol>
<p>In your <strong>UITableViewController</strong> class modify <strong>viewDidLoad</strong> to contain the following (the editing = YES line is optional &#8211; just showing you how to display those cool delete widgets):</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><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>
&nbsp;
	self.tableView.editing <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;	<span style="color: #11740a; font-style: italic;">// Enable delete buttons.</span>
&nbsp;
	UIView <span style="color: #002200;">*</span>hView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> loadNibNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;HeaderView&quot;</span> owner<span style="color: #002200;">:</span>self options<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> objectAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	self.tableView.tableHeaderView <span style="color: #002200;">=</span> hView;
&nbsp;
	UIView <span style="color: #002200;">*</span>fView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> loadNibNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;FooterView&quot;</span> owner<span style="color: #002200;">:</span>self options<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> objectAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	self.tableView.tableFooterView <span style="color: #002200;">=</span> fView;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>As far as I can tell you can&#8217;t lock the header and footer in place.  That will require a custom table view.</p>
]]></content:encoded>
			<wfw:commentRss>http://mitchallen.com/iphone/archives/172/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
