これについて簡単な説明があると確信しています。 私はデータを(ストアではなく)転送するが、ユーザーが入力したテキストをテキストフィールドに転送し、それを別のViewControllerのUILabelとして表示することを検討しています。 私はすでに、ユーザーが入力したテキストを同じviewcontrollerのラベルに変換する方法を知っています。 私の問題がインポートされていると思います。ビューコントローラを使ってUITextFieldをUILabelに変換する
.H:
@interface ViewController : UIViewController {
IBOutlet UITextField *firstPerson;
IBOutlet UITextField *secondPerson;
IBOutlet UIButton *calculateButton;
NSString *firstName;
NSString *secondName;
}
@property (nonatomic, retain) IBOutlet UITextField *firstPerson;
@property (nonatomic, retain) IBOutlet UITextField *secondPerson;
@property (nonatomic, retain) NSString *firstName;
@property (nonatomic, retain) NSString *secondName;
@property (nonatomic, retain) IBOutlet UIButton *calculateButton;
-(IBAction)calculate;
@end
.M:
-(IBAction)calculate {
//Linked to UIButton
//This is the first View Controller.
// firstName = firstPerson.text;
// secondName = secondPerson.text;
secondViewController = [[ShowStats alloc] init];
}
私secondviewコントローラ.M(SHOWSTATS):
#import "ShowStats.h"
#import "ViewController.h"
- (void)viewDidLoad
{
firstName = firstPerson.text;
secondName = secondPerson.text;
[super viewDidLoad];
}
多くの感謝! EDIT
ViewController.h
#import <UIKit/UIKit.h>
#import "ShowStats.h"
@interface ViewController : UIViewController {
IBOutlet UITextField *firstPerson;
IBOutlet UITextField *secondPerson;
IBOutlet UIButton *calculateButton;
//NSString *firstName;
// NSString *secondName;
}
@property (nonatomic, retain) IBOutlet UITextField *firstPerson;
@property (nonatomic, retain) IBOutlet UITextField *secondPerson;
//@property (nonatomic, retain) NSString *firstName;
//@property (nonatomic, retain) NSString *secondName;
@property (nonatomic, retain) IBOutlet UIButton *calculateButton;
-(IBAction)calculate;
@end
ViewController.m
#import "ViewController.h"
#import "ShowStats.h"
@implementation ViewController
@synthesize firstPerson, secondPerson;
//@synthesize firstName, secondName;
@synthesize calculateButton;
ShowStats *secondViewController;
-(IBAction)calculate {
secondViewController = [[ShowStats alloc] init];
secondViewController.firstName = firstPerson.text;
}
ShowStats.h
@interface ShowStats : UIViewController{
IBOutlet UILabel *nameStats;
}
@property (nonatomic, retain) IBOutlet UILabel *nameStats;
@property (nonatomic, retain) NSString *firstName;
@property (nonatomic, retain) NSString *secondName;
@end
ShowStats.m
- (void)viewDidLoad
{
nameStats.text = [NSString stringWithFormat:@"%@", firstName];
//secondLabel.text = self.secondName;
[super viewDidLoad];
}
ラベルが – ZachBamberger
チェックすべてのアウトレットが正しく –