ios - After creating a Custom CellView of a tableView, still i am not getting the multiple column view. Can anyone help me out? -


i having app wherein have created custom cell uitableviewcell. in main view need 4 rows 4 columns. not getting column view, rows seen in screenshot. enter image description here

i went through many related post did not understand them clearly. can give me exact explanations , related code?

if got question , of comments right, table 4 columns required. approach realize such view following.

  • add uitableviewcontroller in storyboard.
  • choose dynamic prototypes cells (and optionally set number of cells 2, if add header row later on).
  • select cell , set style custom.
  • set cell's identifier "warehousecell".
  • set header cell's identifier "headercell".
  • add 4 uilabels each cell , arrange them required.
  • give uilabels of "warehousecell" tags 1 4.

assuming have data model consists of array of dictionaries store warehouses (e.g. @property nsarray *warehouses;), implement in uitableviewcontroller subclass...

- (void)viewdidload {     [super viewdidload];      self.warehouses = @[                         @{@"warehouse":@"1",@"location":@"north pole",@"stock":@"1.200",@"available":@"yes"},                         @{@"warehouse":@"2",@"location":@"south pole",@"stock":@"0",@"available":@"no"},                         @{@"warehouse":@"7",@"location":@"moon base",@"stock":@"8.500",@"available":@"yes"},                         @{@"warehouse":@"10",@"location":@"mars",@"stock":@"n/a",@"available":@"n/a"}                        ]; }  #pragma mark - table view  - (nsinteger)numberofsectionsintableview:(uitableview *)tableview {     return 1; }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     return self.warehouses.count + 1; }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     uitableviewcell *cell;      if (indexpath.row == 0) {         cell = [tableview dequeuereusablecellwithidentifier:@"headercell" forindexpath:indexpath];     } else {         cell = [tableview dequeuereusablecellwithidentifier:@"warehousecell" forindexpath:indexpath];         ((uilabel*)[cell viewwithtag:1]).text = [self.warehouses[indexpath.row-1] valueforkey:@"warehouse"];         ((uilabel*)[cell viewwithtag:2]).text = [self.warehouses[indexpath.row-1] valueforkey:@"location"];         ((uilabel*)[cell viewwithtag:3]).text = [self.warehouses[indexpath.row-1] valueforkey:@"stock"];         ((uilabel*)[cell viewwithtag:4]).text = [self.warehouses[indexpath.row-1] valueforkey:@"available"];     }      return cell; } 

the resulting view should this, make ios7-esque looking table.

table example running in simulator


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -