iphone - popViewControllerAnimated 不更新信息 iPhone SDK

标签 iphone uitableview ios uiview

当我尝试弹出一个 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/

相关文章:

iphone - 更改 UINavigationController 过渡效果的正确方法是什么

iphone - 针对手持式样式表

ios - 按比例调整正方形图像的大小

ios - 如何在 UIStackView 中无间隙地定位旋转的 UILabel?

iphone - 调试 iPhone 应用程序时,Apple xcode 线程的含义是什么?

iphone - 如果不在 iphone 应用程序中向下滚动,Scrollview 不会显示其内容的顶部

ios - 2 具有不同自定义单元格的 UITableView

ios - 当我点击 UIPopoverController 中的一个单元格时推送一个新的 UIViewController

ios - 如何从info.plist判断一个App是否通用?

IOS 11+ 定位服务授权失败,即使 key 存在