我在RegisterViewController
中有tableviewcell
,当我点击它时,它会推送到SelectCityViewController
,我可以从uipickerview
中选择一个城市。我已经在SelectCityViewController
中定义了一位代表。但是,当我实施代表方法时,我从pickerview
和indexpath
从didSelectRowAtIndexPath
RegisterViewController
得到了城市。当我检查日志时,我得到了城市,并选择了indexpath
。但是当我打电话给reloadRowsAtIndexPaths
时,单元格仍然有旧的titlelabel文本。验证码:uitableview reloadRowsAtIndexPaths不工作
SelectCityViewController.h
@protocol SelectCityDelegate <NSObject>
- (void)didGetCity:(City *)city;
@end
SelectCityViewController.m
- (void)finished:(UIBarButtonItem *)buttonItem
{
if ([self.delegate respondsToSelector:@selector(didGetCity:)]) {
[self.delegate didGetCity:self.city];
}
NSLog(@"%@", self.city.city);
[self.navigationController popViewControllerAnimated:YES];
}
RegisterViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 2) {
self.selectedIndexPath = indexPath;
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
SelectCityViewController *signUp = [storyBoard instantiateViewControllerWithIdentifier:@"SignVC"];
signUp.delegate = self;
[self.navigationController pushViewController:signUp animated:YES];
}
}
- (void)didGetCity:(City *)city
{
NSLog(@"%@", city.city);
NSLog(@"%@", selectedIndexPath);
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:selectedIndexPath];
cell.textLabel.text = city.city;
[self.tableView reloadRowsAtIndexPaths:@[selectedIndexPath] withRowAnimation:UITableViewRowAnimationFade];
}
有什么错误?如果在重新加载tableview之后发生错误,那么使用错误日志编辑您的问题。 – Tirth 2013-03-26 06:35:13
没有错误。 titlelabel.text不会改变。 – 2013-03-26 09:16:43