I want UITableView
to show cells in section separated (have distance, blank space, between them).
So I've come up with this:
InventoryViewController.m
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [[[InventoryStore sharedInventory] allInventories] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
Inventory *p = [[[InventoryStore sharedInventory] allInventories]
objectAtIndex:[indexPath section]];
StepperCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"StepperCell"];
[cell setController:self];
[cell setTableView:tableView];
[[cell nameLabel] setText:[p inventoryName]];
[[cell valueLabel] setText:
[NSString stringWithFormat:@"$%d", [p value]]];
[[cell quantityLabel] setText:
[NSString stringWithFormat:@"%d", [p quantity]]];
cell.stepper.value = [p quantity];
return cell;
}
and of course in AppDelegate.m
InventoryViewController *inventoryViewController = [[InventoryViewController alloc] initWithStyle:UITableViewStyleGrouped];
My question is, is there a better or simpler way to separate cells, but in the same section? I want to have one section, and draw data from one array, but these cells should have distance between each other.