2010-05-26
セパレート付きのUITableViewを使ってみた
セパレート付きのUITableViewを使ってみました。
TableAppDelegate.h
第2セクションに表示する配列を定義しました。
@interface TableAppDelegate : NSObject <UIApplicationDelegate, UITableViewDataSource> {
NSArray* names;
NSArray* macNames;
UIWindow *window;
}
TableAppDelegate.m
@implementation TableAppDelegate @synthesize window; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch // namesを初期化 names = [[NSArray arrayWithObjects:@"iPhone", @"iPod touch", @"iPod nano", nil] retain]; // macNamesを初期化 macNames = [[NSArray arrayWithObjects:@"iMac", @"Mac Pro", @"Macbook", @"MacBook Pro", nil] retain]; [window makeKeyAndVisible]; return YES; } - (void)dealloc { [window release]; [super dealloc]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // セクションの数を返す return 2; } - (NSString*)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section { NSString* sectionTitle = nil; switch (section) { case 0: sectionTitle = @"iPhone Names"; break; case 1: sectionTitle = @"Mac Names"; break; default: sectionTitle = nil; break; } return sectionTitle; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSInteger cnt = 0; switch (section) { case 0: cnt = [names count]; break; case 1: cnt = [macNames count]; break; default: cnt = 0; break; } return cnt; } - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { // セルを作る UITableViewCell* cell; cell = [tableView dequeueReusableCellWithIdentifier: @"UITableViewCell"]; if (!cell) { cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier: @"UITableViewCell"]; [cell autorelease]; } if (indexPath.section == 0) { cell.text = [names objectAtIndex:indexPath.row]; } else if (indexPath.section == 1) { cell.text = [macNames objectAtIndex:indexPath.row]; } return cell; } @end
トラックバック - http://d.hatena.ne.jp/ch3cooh393/20100526/1274861834
リンク元
- 67 http://www.appbank.net/2010/05/27/iphone-news/126085.php
- 23 http://pipes.yahoo.com/pipes/pipe.info?_id=3572f9da2c8db3951cc02c59f68f43ba
- 8 http://www.google.co.jp/reader/view/?hl=ja&tab=wy
- 8 http://www.google.co.jp/search?sourceid=navclient&hl=ja&ie=UTF-8&rlz=1T4DBJP_jaJP297JP297&q=C#+Pow+距離
- 5 http://blogs.wankuma.com/ch3cooh/archive/2009/01/05/165634.aspx
- 4 http://ch3cooh.jp/
- 4 http://iddy.jp/profile/CH3COOH/
- 4 http://www.google.co.jp/search?hl=ja&source=hp&q=Pixivビューアー&aq=f&aqi=g-c1&aql=&oq=&gs_rfai=
- 3 http://d.hatena.ne.jp/naka_P/
- 3 http://d.hatena.ne.jp/tmatsuu/20090211/1234369894

CH3COOH / Kenji WadaMicrosoft MVP for Device Application Development(Jul 2010 - Jun 2012)