<?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>simra &#187; UITableView</title>
	<atom:link href="http://www.simra.ch/tag/uitableview/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simra.ch</link>
	<description>development &#38; design</description>
	<lastBuildDate>Fri, 26 Mar 2010 15:57:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iPhone Tutorial 1 (UITableView)</title>
		<link>http://www.simra.ch/2010/02/iphone-tutorial-1-uitableview/</link>
		<comments>http://www.simra.ch/2010/02/iphone-tutorial-1-uitableview/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 20:39:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[UITableView]]></category>

		<guid isPermaLink="false">http://www.simra.ch/?p=1105</guid>
		<description><![CDATA[In diesem ersten Tutorial geht es darum ein einfaches iPhone-App betehend aus einem UITableView zu erstellen. Es soll zeigen, wie ein Text in eine Zelle dieser Table-Übersicht geschrieben wird.

Wenn die iPhone SDK bereits installiert wurde, erscheint das folgende Fenseter mit den iPhone Projekt Templates. Wählen Sie das Erste &#8220;Navigation-Based Application&#8221; und geben Sie ein Projektname [...]]]></description>
			<content:encoded><![CDATA[<p>In diesem ersten Tutorial geht es darum ein einfaches iPhone-App betehend aus einem UITableView zu erstellen. Es soll zeigen, wie ein Text in eine Zelle dieser Table-Übersicht geschrieben wird.<br />
<span id="more-1105"></span><br />
Wenn die iPhone SDK bereits installiert wurde, erscheint das folgende Fenseter mit den iPhone Projekt Templates. Wählen Sie das Erste &#8220;Navigation-Based Application&#8221; und geben Sie ein Projektname (Hier tutorial-1).</p>
<p><img class="aligncenter size-full wp-image-1110" title="iphone-new-project" src="http://www.simra.ch/wordpress/../uploads/2010/02/iphone-new-project.png" alt="" width="450" height="332" /></p>
<p>Wenn Sie unmittelbar nach dem Erstellen des Projekts auf <strong>&#8220;Build and Go&#8221;</strong> klicken erscheint eine leere Table-Übersicht. Als nächstes werden wir eine neue Zeile mit Text hinzufügen.</p>
<p>Dazu öffnen Sie die Datei RootViewController.m (Mehr zur Bedeutung der Standard Dateien finden Sie <a title="iPhone SDK Standard Dateien" href="http://www.simra.ch/2010/02/iphone-sdk-standard-dateien/" target="_blank">hier</a>). Das ist der View-Controller, also hier der TableView der zur Hauptansicht (main view) hinzugefügt wird.</p>
<p>Suchen Sie die Funktion <strong>numberOfRowsInSection</strong>.</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: #11740a; font-style: italic;">// Customize the number of rows in the table view.</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView numberOfRowsInSection<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>section <span style="color: #002200;">&#123;</span><br />
<span style="color: #a61390;">return</span> <span style="color: #2400d9;">1</span>;<br />
<span style="color: #002200;">&#125;</span></div></div>
<p>Hier wird die Anzahl der Zeilen festgelegt. Ändern Sie den Rückgabewert von 0 auf 1, um dem Programm mitzuteilen, dass wir eine Zeile haben wollen.</p>
<p>Als nächstes muss die Funktion <strong>cellForRowAtIndexPath</strong> angepasst werden. Diese Funktion wird für jede Zeile einmal aufgerufen. Hier kann auch der Zellentext gesetzt werden.</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: #11740a; font-style: italic;">// Customize the appearance of table view cells.</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>UITableViewCell <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView cellForRowAtIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>indexPath <span style="color: #002200;">&#123;</span><br />
<br />
<span style="color: #a61390;">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>CellIdentifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cell&quot;</span>;<br />
<br />
UITableViewCell <span style="color: #002200;">*</span>cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>cell <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UITableViewCell alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>CGRectZero reuseIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">// Set up the cell...</span><br />
<span style="color: #002200;">&#91;</span>cell setText<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Hier kommt unser Text&quot;</span><span style="color: #002200;">&#93;</span>;<br />
<br />
<span style="color: #a61390;">return</span> cell;<br />
<span style="color: #002200;">&#125;</span></div></div>
<p>Der Funktion wurde nur der Aufruf der Methode <strong>setText</strong> der Zelle mit dem Parameter <strong>&#8220;Hier kommt unser Text&#8221;</strong> hinzugefügt. Dass &#8220;@&#8221; muss beim Objective-C vor jedem String stehen.<br />
<em>[cell setText:@"Hier kommt unser Text"];</em></p>
<p>Wenn Sie jetzt wieder auf <strong>&#8220;Build and Go&#8221;</strong> klicken erscheint der Text <strong>&#8220;Hier kommt unser Text&#8221;</strong> in der Zelle.</p>
<p><img class="aligncenter size-full wp-image-1122" title="result-tutorial-1" src="http://www.simra.ch/wordpress/../uploads/2010/02/result-tutorial-1.png" alt="" width="319" height="157" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simra.ch/2010/02/iphone-tutorial-1-uitableview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

