更改tableview的单元格的标签和图标位置

问题描述:

它可以改变位置哦图像和标签我的tableview的单元格? 我不会用CustomCell ..更改tableview的单元格的标签和图标位置

我已经尝试了本(用于标签)..

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

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

    UIImage *image = nil; 

      cell.textLabel.text = @"text label"; 
      UILabel *label = cell.textLabel; 
      CGRect frame = label.frame; 
      frame.origin.x = 62; 
      frame.origin.y = 62; 
      label.frame = frame; 
      image = [UIImage imageNamed:@"icon.png"]; 


    cell.textLabel.font = [UIFont boldSystemFontOfSize:FONT_SIZE]; 
    cell.accessoryType = UITableViewCellAccessoryNone; 
    cell.imageView.image = image; 

    return cell; 

}

+2

[http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/TableView_iPhone/TableViewCells/TableViewCells.html](http://developer。 apple.com/library/ios/#documentation/userexperience/conceptual/TableView_iPhone/TableViewCells/TableViewCells.html)你可以参考这个文档。它包括默认&custome单元格。 – Kjuly

请把一个UIview..and给帧大小相同的单元尺寸。 ..之后,在该视图中添加标签...也无论您想添加..添加为该视图中的子视图...,而不是将该视图添加到单元格中。

万事如意

//table cell contains title,date,image 

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


       static NSString *CellIdentifier = @"Cell"; 

      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
      cell =nil; 
      [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 

      if (cell == nil) 

      { 
         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ; 
      } 

     //tittle label  

     UILabel *titleLabel = [[UILabel alloc] initWithFrame:contentFrame] ; 
      titleLabel.numberOfLines = 2; 
      titleLabel.font = [UIFont boldSystemFontOfSize:12]; 
      titleLabel.text = [currentTweet title]; 
      [cell.contentView addSubview:titleLabel]; 

    //date label 

     UILabel *dateLabel = [[UILabel alloc] initWithFrame:dateFrame]; 
      dateLabel.font = [UIFont systemFontOfSize:10]; 
      dateLabel.text = [currentTweet dateCreated]; 
      [cell.contentView addSubview:dateLabel]; 

    //image view 
     CGRect imageFrame = CGRectMake(2, 8, 40,50);  
      self.customImage = [[UIImageView alloc] initWithFrame:imageFrame]; 
      customImage.image =image; 
     [cell.contentView addSubview:self.customImage]; 
     return cell;