2013-05-07 5 views
0

Я хочу создать более подробные ячейки таблицы. Примером, который я нашел, является клиент AlidBlue reddit.com. Каждая ячейка имеет изображение, название сообщения, затем под ним четыре других фрагмента текста. Как я могу «сложить» текст в ячейке таблицы?Создание более подробных ячеек таблицы

ответ

6

Привет, вы должны подкласс UITableViewCell для пользовательского интерфейса пользователя в виде таблицы. Также посмотрите на: UITableViewDataSource и UITableViewDelegate на другие варианты в отношении вида стола.

Вероятно, ваш подклассов UITableViewCell будет иметь пользовательские поля для заголовка (UILabel), подписи (UILabel) и изображения (UIImageView)

Примеры:

  1. Crafting Custom UITableView Cells

  2. Customize Table View Cells For UITableView

2

Вы хотите, чтобы у вас был возможность произвести заказ UITableViewCell. Это довольно тривиально, и может быть сделано либо полностью в коде (мой любимый), либо через IB.

Google custom UITableView cell для некоторых отличных уроков.

1
  1. Использование NSMutableArrayNSMUtableDictionary, в отличие от NSArray или NSMutableArray, для хранения данных (строк, изображений, ...).
  2. Задайте свойство стиля ячейки таблицы UITableViewCellStyleSubtitle, чтобы таблица могла отображать подробныйTextLabel (cell.detailTextLabel.text).
  3. Вы можете установить изображение в ячейку таблицы.

Пример

- (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]; 
} 
// Configure the cell... 
UIImage *image = [[list1 objectAtIndex:indexPath.row] objectForKey:key1a]; 
cell.imageView.image = image; 
NSString *categoryname = [[list1 objectAtIndex:indexPath.row] objectForKey:key1b]; 
cell.textLabel.text = categoryname; 
cell.detailTextLabel.text = [[list1 objectAtIndex:indexPath.row] objectForKey:key1e]; 
cell.detailTextLabel.textColor = [UIColor blueColor]; 
return cell; 
} 
0
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 

     static NSString *CellIdentifier = @"Cell"; 
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
     if (cell == nil) 
     { 
      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
     } 

     cell.textLabel.text=[NSString stringWithFormat:@"%@",[appdelegate.name objectAtIndex:indexPath.row]]; 

     UIImage *image = [[array1 objectAtIndex:indexPath.row]; 

     cell.detailTextLabel.text = [[array1 objectAtIndex:indexPath.row]; 


     return cell; 
    } 
Смежные вопросы