0

私はsqliteで名前でデータを並べ替えました:

     char*sql="SELECT* FROM tblcocktail ORDER BY drinkname ;";

文字でソートされた表に表示する方法がわかりません:アドバイスしてください:)

-(void)viewDidAppear:(BOOL)animated
{
Cocktails*cock=[[Cocktails alloc]init];
_arrcocktail=[cock getallcocktail];
[self.tableView reloadData];

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
 // Return the number of sections.
 return [_arr count]; //all the letters
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
  //i don't not what to put here so it will show me the right name under the right letter
}
4

1 に答える 1

0

セルを作成して名前を割り当てるだけです。

tableView:cellForRowAtIndexPath:

static NSString *CellIdentifier = @"CellIdentifier";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Configure the cell...

cell.textLabel.text = [_arr objectAtIndex:indexPath.row];

return cell;
}
于 2012-10-26T19:20:33.490 に答える