기본적으로다가 테이블 뷰 세팅 값들
//
// 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
'아이폰' 카테고리의 다른 글
아이폰 스레드 쓰는 방법 (0) | 2011.10.19 |
---|---|
Objective c 정리 (0) | 2011.07.01 |
WindowBased로 생성한 프로젝트에 UIViewController붙이기 UINavigationController 붙이기 아이폰 (0) | 2011.06.30 |
UICatalog iphone ui sample source 대박 아이폰 유아이 샘플 소스들 모음집 (0) | 2011.06.29 |
아이폰 아이콘 설정 (0) | 2011.04.18 |