ios - 如何在按钮触摸时填充 UITableView

标签 ios uitableview button populate

所以我正在为 iOS 构建一个应用程序,我已经得到它来计算一堆东西并将它们显示在屏幕上,在 -(IBAction)calculate 上。 它还构建了一个递增数组,该数组将是一个切割列表。有一个空白的 UITableView 沿着 View 的一侧向下延伸。我在 viewDidLoad 之后有它。现在,当我按下计算按钮时,我想用递增的切割列表填充此列表。我找不到任何教程等来帮助我解决这个问题。

当我将它放入计算操作时,它只会给我错误。 所以我把它留在 viewDidLoad 之后,并希望通过触摸按钮填充它。

这是我的:

// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}

// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [creeperArray count];
}

// Customize the appearance of table view cells.
- (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] autorelease];
}

// Configure the cell.
[cell.textLabel setText:[creeperArray objectAtIndex:indexPath.row]];

return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

/*
 <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
 // ...
 // Pass the selected object to the new view controller.
 [self.navigationController pushViewController:detailViewController animated:YES];
 [detailViewController release];
 */
}

最佳答案

告诉您的 TableView reloadData。如果它的委托(delegate)和数据源设置正确,并且 creeperArray 包含您想要显示的内容,它应该可以工作。

(如果没有,您需要提供更多详细信息。)

关于ios - 如何在按钮触摸时填充 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10555688/

相关文章:

ios - Xcode UITableView 放置和单元格分隔符

iOS 核心位置 : How to disable the default iOS pop-up message for user permission

ios - TableView 重新加载数据后 TableView 单元格布局不正确

ios - CoreGraphics 确定模拟器中的点击位置 - 架构 i386 的 undefined symbol

ios - 如何在自动布局中使用 UITableViewCell 的动态高度并在隐藏底部 View 时将其他 View 向上移动?

android - 根据Android中EditText中的文本启用和禁用Button

ios - CFNetwork SSLHandshake 失败 (-9806) & (-9800) & (-9830)

ios - 突出显示 uitableViewCell

css - 如何在 IOS Safari 的 CSS 中模拟事件按钮?

带有圆形颜色、背景图像和选择器的 Android 按钮