我有ViewcontrollerA
作为表单填写页面并执行计算我现在推送新的viewcontrollerB
当我弹出ViewcontrollerA
现有内容被清除
我的代码是
在viewcontroller A中
JS_skill *skill_VC = [[JS_skill alloc] initWithNibName:@"JS_skill" bundle:nil];
[[self navigationController] pushViewController:skill_VC animated:NO];
在viewcontroller B中
[self.navigationController popViewControllerAnimated:YES];
答案 0 :(得分:1)
快速选项是在推送viewcontroller之前将文本字段的值保存在userDefaults中。然后当你在viewWillAppear中返回viewController时,将textfields设置回userDefaults中的内容:
//Just before you push the viewController:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:@"Example Name" forKey:@"nameTextField"];
[defaults setValue:@"Example Surname" forKey:@"surnnameTextField"];
//In ViewWillAppear:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
textField.text = [defaults valueForKey:@"nameTextField"];
surnameField.text = [defaults valueForKey:@"surnnameTextField"];