Skip to content

Instantly share code, notes, and snippets.

@thoretton-edwin
Last active August 29, 2015 13:56
Show Gist options
  • Save thoretton-edwin/9015907 to your computer and use it in GitHub Desktop.
Save thoretton-edwin/9015907 to your computer and use it in GitHub Desktop.
iOS TableView cell methods with tab of NSDictionnary. tags : UITableView,UITableViewCell,cell,table view
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tab count];
}
- (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];
// Configure the cell...
cell.textLabel.text = [[tab objectAtIndex:indexPath.row] objectForKey:@"nom"];
cell.backgroundColor = [[tab objectAtIndex:indexPath.row]objectForKey:@"couleur"];
/* other methods of standard cell
[cell.textLabel setText:@"text"];
[cell.detailTextLabel setText:@"text"];
[[cell textLabel]setFont:[UIFont boldSystemFontOfSize:24]];
[[cell detailTextLabel]setFont:[UIFont systemFontOfSize:16]];
We can config the imageView of cell too ...
*/
}
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment