1つのビューでUITextFieldsに入力されたテキストを取得し、ボタンが押されたときにそれらの値を別のViewControllerに渡そうとしています。最初のビューコントローラ(CreateViewController)には、次のものがあります。
#import <UIKit/UIKit.h>
#import <MessageUI/MFMailComposeViewController.h>
@class ThePreviewViewController;
@interface CreateViewController : UIViewController <UIAlertViewDelegate, MFMailComposeViewControllerDelegate> {
UIDatePicker *datePicker;
UIDatePicker *datePicker2;
ThePreviewViewController *_thePreview;
}
@property (nonatomic, retain) IBOutlet UITextField *toName;
@property (nonatomic, retain) IBOutlet UITextField *fromName;
@property (nonatomic, retain) IBOutlet UITextField *issue;
@property (nonatomic, retain) ThePreviewViewController *thePreview;
@property (nonatomic, retain) IBOutlet UITextField *expire;
@property (nonatomic, retain) IBOutlet UITextField *loveMessage;
@property (nonatomic, retain) IBOutlet UITextField *gift;
-(IBAction)build;
@end
実装ファイルは次のとおりです。
#import "ThePreviewViewController.h"
@implementation CreateViewController
@synthesize toName, fromName, gift, loveMessage, issue, expire, datePicker, datePicker2;
@synthesize thePreview = _thePreview;
-(IBAction)preview {
if (_thePreview == nil) {
self.thePreview = [[ThePreviewViewController alloc] initWithNibName:@"ThePreviewViewController" bundle:[NSBundle mainBundle]] ;
}
_thePreview.issue.text = issue.text;
_thePreview.gift.text = gift.text;
_thePreview.expire.text = expire.text;
[self.navigationController pushViewController:_thePreview animated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
ただし、すべてのアウトレットを接続した後、ThePreviewViewControllerのラベルはnullのままになります。考え?