スキップしてメイン コンテンツに移動

投稿

4月, 2013の投稿を表示しています

UITableViewのセクションについて

UITableView セクションの設定 ■適当にデータを用意する // セクション名 keys = [[NSArray alloc] initWithObjects:@"0", @"1", @"2", nil]; // 各セクションに入れるデータを作成 NSArray *section1 = [NSArray arrayWithObject:@"A", @"B", @"C", nil]; NSArray *section2 = [NSArray arrayWithObject:@"D", @"E", @"F", nil]; NSArray *section3 = [NSArray arrayWithObject:@"G", @"H", @"I", nil]; NSArray *sections = [NSArray arrayWithObject:section1, section2, section3, nil]; // セクション名とデータを合わせ込む dataSource = [[NSDictionary alloc] initWithObjects:sections forKeys:keys]; ■セクション名、セクション数、セクションに含まれる行を返すようにする // セクション名を返す - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return [key objectAtIndex:section]; } // テーブルに含まれるセクションの数 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [keys count]; } // セクションに含まれる行の数 - (NSInteger)tableView:(UITa...