2009-09-10 5 views
0

Je veux faire une vue de table dans mon application iPhone .. Dans ce tableau, chaque doit contenir 1 image, un texte de ligne, des symboles, etc. Je ne sais pas comment personnaliser notre cellule de table. S'il vous plaît fournir de l'aide si vous avez ..Personnalisation des cellules dans l'application iPhone

Répondre

2

Je pense que vous pouvez utiliser un défaut UITableViewCell pour faire ce que vous avez décrit en initialisant la cellule (en - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath) avec le UITableViewCellStyle approprié

par exemple:

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

static NSString *CellIdentifier = @"Cell"; 

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

// Set up the cell... 

return cell; 

}

qui vous donne. « un style pour une cellule avec une étiquette aligné à gauche dans la partie supérieure et une étiquette aligné à gauche ci-dessous dans plus petit texte gris l'INTRODUCTION eN BOURSE L'application utilise des cellules dans ce style. " Chaque type de UITableViewCell possède également une propriété image par défaut.

mais voici quelques tutoriels pour la construction de cellules personnalisées:

Custom UITableViewCells with Interface Builder

http://iphone.zcentric.com/2008/08/05/custom-uitableviewcell/

2

Vous pouvez créer une cellule dans Interface Builder. Commencez avec un UITableViewCell qui agit comme une vue, puis ajoutez un UIImage, une ou plusieurs étiquettes, n'importe quels conteneurs pour contenir vos symboles, etc.

Puis dans votre cellForRowAtIndexPath, chargez la plume et remplissez l'image et les étiquettes, etc.

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

    static NSString *CellIdentifier = @"Cell"; 

    MyTableCell *cell = (MyTableCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) {  
     cell = myTableCell; // get the object from the outlet 
     myTableCell = nil; // make sure this can't be re-used accidentally 
    } 


    // Set up the cell... 
    cell.myViewController = self; 
    // set up image and labels here 
    return cell; 
} 
Questions connexes