ser*_*487 19 objective-c uitableview ios
我使用数组初始化表中viewDidLoad的数据,然后将数据添加到单元格.这是我在书中读到的标准方法.这就是我所拥有的:
- (void)viewDidLoad {
[super viewDidLoad];
//Create array and add data ("tableViewValues" is initialized in .h file)
tableViewValues = [[NSMutableArray alloc]init];
[tableViewValues addObject:@"$280,000.00"];
[tableViewValues addObject:@"$279,318.79"];
}
// 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];
}
NSString *cellValue = [tableViewValues objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
因此,当视图加载时,这两个货币值都在我的表中.现在在另一个函数中,我根据用户在文本字段中输入的内容填充另一个具有不同货币编号的数组.如何更新当前的表视图并将这些值替换为其他数组中的值?谁能帮我?谢谢!
Jam*_*mie 42
你可以打电话
[self.tableView reloadData];
Run Code Online (Sandbox Code Playgroud)
但是,要重新加载所有数据,您需要编写一种方法来使您想要填充表的数组.也许你希望你的-cellForRowAtIndexPath调用一个有条件地选择正确数组的私有方法.
| 归档时间: |
|
| 查看次数: |
43649 次 |
| 最近记录: |