2011-03-06 20 views

Respuesta

1

Bueno, para agregar una imagen a una celda de tabla, agregaría un UIImage a la propiedad de imagen de un subtítulo UITableViewCell o su propia Celda personalizada. Leería el documento sobre Personalización de UITableViewCells en developer.apple.com.

18
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath 
{  
    static NSString* CellIdentifier = @"Cell"; 

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

    cell.textLabel.text = @"I'm a UITableViewCell!"; 
    cell.imageView.image = [UIImage imageNamed:@"MyReallyCoolImage.png"]; 

    return cell; 
} 

crédito a Thomas Moore

adding images to UItableView

0

versión Swift:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 

    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell 

    cell.textLabel.text = "I'm a UITableViewCell!"; 
    cell.textLabel.textColor = UIColor.whiteColor() 
    cell.imageView.image = UIImage(named: "MyReallyCoolImage.png") 

    return cell; 
} 
Cuestiones relacionadas