【发布时间】:2013-06-13 00:31:02
【问题描述】:
我想做一个应用,它包括表单提交。在此我通过单视图应用程序创建一个新项目。在这个 firstViewController 中,我放置了按钮并按下它,它重定向到 secondViewController。
在这我有一个表格。并想从用户那里获取数据并通过提交按钮我想将其重定向到 thirdViewController 并希望在 thirdViewController 上打印表单数据。
在我写的 firstViewController.m 文件中
-(IBAction)nextVCButton:(id)sender
{
SecondViewController *tempView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
NSLog(@"name : %@",self.nameTextField.text);
tempView.fullName = self.nameTextField.text;
[tempView setFullName:self.fullName];
[self.view addSubview:tempView.view];
}
在 SecondViewController.m 文件中
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSLog(@"received info %@", [self.fullName description]);
self.nameLabel.text = [self.fullName description];
}
在日志中我正在获取 (name :) 值,但在 secondViewController 中收到的信息为空。
我通过使用 xib 文件来完成这一切。不使用情节提要。
请帮我把这个表单数据传给 secondViewController。
谢谢。
【问题讨论】:
-
使用 addsubview 加载第二个视图控制器?严重吗?那为什么要创建
UINavigationController类? -
哪种方式更适合通过按钮将一个视图导航到另一个视图并再次从该控制器通过按钮导航到第三个控制器?
标签: iphone xib viewcontroller