@interface RootViewController : UITableViewController { NSMutableArray *listOfItems; } |
- (void)viewDidLoad { [super viewDidLoad];
listOfItems = [[NSMutableArray alloc] init];
// Initalize [listOfItems addObject:@"유딩이유"]; [listOfItems addObject:@"초딩이유"]; [listOfItems addObject:@"중딩이유"]; [listOfItems addObject:@"고딩이유"]; [listOfItems addObject:@"아이유><"];
// set title self.navigationItem.title = @"IU Love";
// Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; } |
// Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [listOfItems count]; } |
- Cell을 초기화 하고 Cell에 위에서 만든 리스트의 데이터를 넣어줍니다.
// Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; }
// Configure the cell. NSString *cellValue = [listOfItems objectAtIndex:indexPath.row]; [[cell textLabel] setText:cellValue];
return cell; } |
1. RootViewController.h 파일에 코드 추가 - 데이터를 담을 Array 객체 선언 2. RootViewController.m 파일에 코드 추가 - 데이터 넣기, - 데이터를 담았던 객체 메모리 해제 - 리스트 크기 - Cell set |
'General > iOS' 카테고리의 다른 글
[iPhone] parsing, tableview (0) | 2010.12.26 |
---|---|
[iPhone] 메모리 관리 (0) | 2010.12.21 |
[iPhone] TableView CustomCell delegate, datasource connection (View based application) (1) | 2010.12.21 |
[iPhone] about TableView (0) | 2010.12.21 |
[iPhone] TableView Custom Cell 만들기 (0) | 2010.12.20 |