一般来说,我对编程非常陌生。我正在尝试制作一个非常简单的应用程序。
我正在尝试使用情节提要将数据从一个视图控制器传递到另一个视图控制器。在我的第一个屏幕上,我有一个文本字段和一个按钮,然后在您按下按钮后,我希望使用您在文本字段中输入的任何文本来更新第二个屏幕的标签。
这是我的一些代码:
#import "FirstViewController.h"
#import "SecondViewController.h"
@interface FirstViewController ()
@end
@implementation FirstViewController
@synthesize secondviewData;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)passData:(UIButton *)sender {
// SecondViewController *second = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
self.secondviewData = secondviewData;
secondviewData.passedValue = input.text;
// [self presentViewController:second animated:YES completion:nil];
homeLabel.text = input.text;
}
@end
#import "SecondViewController.h"
#import "FirstViewController.h"
@interface SecondViewController ()
@end
@implementation SecondViewController
@synthesize passedValue;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
label.text = passedValue;
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
这是我的代码的链接:http: //oberober.com/passingData/
到目前为止,无论我在第一个屏幕的文本字段中输入什么,第二个屏幕上的标签都会保持空白。
我觉得我错过了一个重要的概念?我可以查看任何提示或教程吗?
提前感谢,卡斯帕