当我尝试弹出一个 View Controller 时,它不会更新前一个 View 的信息。示例:我有一个单元格在 View1 的标签中显示文本。当您单击单元格时,它会转到 View2(例如)当我在 View2 中选择一个选项时,popViewControllerAnimated 用于返回到 View1,但是,我希望现在使用 View1 中的新选项更新标签。
我的困境是,当我弹出 View2 时,View1 中的标签没有更新。有任何想法吗?我试过添加 [view1 reloadData];在 View 弹出之前,但没有运气。
//VIEW1 the cell that displays the label.
ringLabel = [[UILabel alloc] initWithFrame: CGRectMake(25, 12.7f, 250, 20)];
ringLabel.adjustsFontSizeToFitWidth = YES;
ringLabel.textColor = [UIColor blackColor];
ringLabel.font = [UIFont systemFontOfSize:17.0];
ringLabel.backgroundColor = [UIColor clearColor];
ringLabel.textAlignment = UITextAlignmentLeft;
ringLabel.tag = 0;
ringLabel.text = [plistDict objectForKey:@"MYOPTION"];
[ringLabel setEnabled:YES];
[cell addSubview: ringLabel];
[ringLabel release];
//VIEW2 when cell clicked
CustomProfileViewController *cpvc = [CustomProfileViewController alloc];
cpvc.ringtone = [ringList objectAtIndex:indexPath.row];
[cpvc.tblCustomTable reloadData];
[self.navigationController popViewControllerAnimated:YES];
最佳答案
您需要覆盖第一个 View Controller 上的 -viewWillAppear:
并更新那里的标签。 (确保同时调用 super
)。
例子:
- (void)viewWillAppear:(BOOL)animated {
// This method is called whenever the view is going to appear onscreen.
// (this includes the first time it appears.)
ringLabel.text = [plistDict objectForKey:@"MYOPTION"];
[super viewWillAppear:animated];
}
关于iphone - popViewControllerAnimated 不更新信息 iPhone SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1892713/