-3

I would like to know if it's possible to have 2 customize cells in one UITableView ?

Because I would like to have two different type of cells in one view : the first row will be big (with white background on screenshot), and after simple row (with red background on screenshot).

Tell me if that's possible or not, and how to make that :)

I let you see what I want to make :

http://www.noelshack.com/2015-13-1427415385-sans-titre.png

Or maybe put a UIView for big label, and after table cell ?

xcode_Dev
  • 237
  • 4
  • 16

1 Answers1

0

There are 2 approaches, assuming that the big screenshot is only on the first row. You could set the table view's property

tableView.tableHeaderView = myHugeImage;

Otherwise, if you design 2 rows using nibs and custom classes, you'll need to call the following in viewDidLoad. Do note that custom classes must be subclasses of UITableViewCell

[tableView registerNib:[UINib nibWithNibName:@"bigrow" bundle:nil] forCellReuseIdentifier:@"big"]
[tableView registerNib:[UINib nibWithNibName:@"normal row" bundle:nil] forCellReuseIdentifier:@"normal"]

If you used classes and no nibs, then you would use registerClass:forCellReuseIdentifier If you used classes and designed the cell directly inside the prototype cell, then neither of those calls are necessary.

Lastly, inside tableView:cellForRowAtIndexPath:

if (indexPath.row == 0) {
    BigRowCell *c = [tableView dequeueReusableCellWithIdentifier:@"big" forIndexPath:indexPath];
    return c;
}
SmallRowCell *c = [tableView dequeueReusableCellWithIdentifier:@"normal" forIndexPath:indexPath];
return c;
Harikrishnan
  • 9,688
  • 11
  • 84
  • 127
Killian
  • 157
  • 2
  • 4