0
我希望UITableView
能够在分隔的部分显示单元格(它们之间有距离,空格)。UITableView中的分隔单元
所以我想出了这一点:
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;
}
,当然在AppDelegate.m
我的问题是,有没有更好的或者更简单的方式来分隔单元格,但在同一部分? 我想有一个部分,并从一个数组中绘制数据,但这些单元之间应该有距离。
你可以试试这个:http://stackoverflow.com/questions/4804632/uitableview-separator-line或本:http://stackoverflow.com/questions/3521310/how-to-increase-the -uitableview-分隔符高度 – brainray