我有一个tableviewcell
,RegisterViewController
当我点击它时,它会推送到SelectCityViewController
我可以从中选择一个城市的地方uipickerview
。我已经在SelectCityViewController
. 但是当我实现委托方法时,我从 中取回了城市并从中pickerview
选择indexpath
了。当我检查日志时,我得到了城市和选定的. 但是当我打电话时,单元格仍然有旧的标题标签文本。编码:didSelectRowAtIndexPath
RegisterViewController
indexpath
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];
}