Wri*_*sCS 3 iphone uitableview uiview ios
当我尝试弹出一个视图控制器时,它不会更新上一个视图的信息.示例:我有一个单元格,在View1的标签中显示文本.单击单元格时,它转到View2(例如)当我在View2中选择一个选项时,popViewControllerAnimated用于返回View1,但是,我希望现在可以使用View1中的新选项更新标签.
我的困境是当我弹出View2时,View1中的标签不会更新.有任何想法吗?我试过添加[view1 reloadData]; 在视图弹出之前,但没有运气.
//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];
Run Code Online (Sandbox Code Playgroud)
您将要覆盖-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];
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5229 次 |
最近记录: |