2011. 7. 1. 00:35 아이폰

기본적으로다가 테이블 뷰 세팅 값들 

//

//  testtabbarmain.h

//  testtabbartest

//

//  Created by sons on 11. 6. 30..

//  Copyright 2011 __MyCompanyName__. All rights reserved.

//


#import <UIKit/UIKit.h>



@interface testtabbarmain : UITableViewController {


NSArray *data;

NSArray *datasection;

}


@property(nonatomic,retain) NSArray *data;

@property(nonatomic,retain)IBOutlet NSArray *datasection;

@end




//

//  testtabbarmain.m

//  testtabbartest

//

//  Created by sons on 11. 6. 30..

//  Copyright 2011 __MyCompanyName__. All rights reserved.

//


#import "testtabbarmain.h"



@implementation testtabbarmain


@synthesize data;//,datasection;


static NSString *kData=@"kData";


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

- (void)viewDidLoad {

    [super viewDidLoad];

data = [[NSArray alloc ]initWithObjects:

[NSDictionary dictionaryWithObjectsAndKeys:@"Data1",kData,nil],

[NSDictionary dictionaryWithObjectsAndKeys:@"Data2",kData,nil],

[NSDictionary dictionaryWithObjectsAndKeys:@"Data3",kData,nil],nil];

}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{//섹션의 갯수 (로우를 그룹으로 가지고있다)

return 2;//[self.dataSourceArray count];

}


- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

{

//섹션의 타이틀 (로우를 그룹으로 가지고있는 섹션의 타이틀 (보통회색바로 나타난다 ))

NSLog(@"titleForHeaderInSection %d %p",section,data);

return [[data objectAtIndex: section] valueForKey:kData];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

//섹션안의 로우 갯수 

return [data count];

}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *CellId = @"cell";

NSLog(@"cellForRowAtIndexPath %d",indexPath.row);


UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellId];

if (cell == nil)

{

// a new cell needs to be created

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault

  reuseIdentifier:CellId] autorelease];

}

cell.textLabel.text = [[data objectAtIndex: indexPath.row] valueForKey:kData];

//cell.detailTextLabel.text =[[data objectAtIndex: indexPath.row] valueForKey:kData];;

    return cell;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

//로우의 높이 나타낸다 

return ([indexPath row] == 0) ? 50.0 : 22.0;

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

/*로우를 눌렀을때 일어나는 액션*/

}

- (void)didReceiveMemoryWarning {

    // Releases the view if it doesn't have a superview.

    [super didReceiveMemoryWarning];

    

}


- (void)viewDidUnload {

    [super viewDidUnload];

   

}



- (void)dealloc {

[datasection release];

[data release];

data = nil;

    [super dealloc];

}



@end


posted by 욱이다