所以我正在为 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/