我目前正在开发我的第一个“大”项目,即货币转换器。当我选择一行时,我希望每个单元格将“nan”标签的值更改为从xmlparse类返回的货币。但是,我不知道我应该如何从didSelectRow方法中调用这段代码。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"doingit");
static NSString *simpleTableIdentifier = @"SimpleTableCell";
SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
// cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
XMLparse *parse = [[XMLparse alloc]init];
[parse setcurrencyname:[Datarray2 objectAtIndex:indexPath.row]];
cell.nameLabel.text = [Datarray2 objectAtIndex:indexPath.row];
cell.prepTimeLabel.text = [NSString stringWithFormat:@"%.9f",[parse convertionrate]];
cell.thumbnailImageView.image = [UIImage imageNamed:[imagearray objectAtIndex:indexPath.row]];
return cell;
}
//didselectrow
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"didSelectRowAtIndexPath");
XMLparse *parse = [[XMLparse alloc]init];
[parse setHowmuchmoney:1];
[parse setValutanamn1:[Datarray objectAtIndex:indexPath.row]];
NSLog(@"%@",[parse valutanamn1]);
[parse loadDataFromXML];
UIAlertView *messageAlert = [[UIAlertView alloc]
initWithTitle:@"Row Selected" message:[Datarray objectAtIndex:indexPath.row] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[messageAlert show];
//call cellForRowAtIndexPath here?
}
答案 0 :(得分:0)
你只需要这样做:
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];