如何将单元格添加到 UITableView?
How do I add a cell to a UITableView?
在我的故事板中,我有一个 UITableView。当按下按钮时(操作是 createGroup:
),我想在 table 视图中创建一个新单元格,暂时使用文本 @"Cell"
。我该怎么做呢?我看了很多问题,但我无法理解任何问题。我需要帮助。
这很正常,除了添加新行(视觉上)之外,您还需要更新数据源(在本例中为通知数组)。 UI 只是数据源的可视化。所以:
[array addObject:@"a new Entry"];
[[self tableView] insertRowsAtIndexPaths:paths
withRowAnimation:UITableViewRowAnimationTop];
当您删除时:
[array removeObjectAtIndex:indexPath.row];
[[self tableView] deleteRowsAtIndexPaths:paths
withRowAnimation:UITableViewRowAnimationTop];
在我的故事板中,我有一个 UITableView。当按下按钮时(操作是 createGroup:
),我想在 table 视图中创建一个新单元格,暂时使用文本 @"Cell"
。我该怎么做呢?我看了很多问题,但我无法理解任何问题。我需要帮助。
这很正常,除了添加新行(视觉上)之外,您还需要更新数据源(在本例中为通知数组)。 UI 只是数据源的可视化。所以:
[array addObject:@"a new Entry"];
[[self tableView] insertRowsAtIndexPaths:paths
withRowAnimation:UITableViewRowAnimationTop];
当您删除时:
[array removeObjectAtIndex:indexPath.row];
[[self tableView] deleteRowsAtIndexPaths:paths
withRowAnimation:UITableViewRowAnimationTop];