【发布时间】:2013-12-10 06:08:18
【问题描述】:
我正在尝试将用户生成的文本从 AuthenticationViewController 发送到 MainProfileViewController。我没有收到错误报告。标签甚至没有出现在 MainProfileViewController 中。插座已正确连接。感谢您的帮助!
#import <UIKit/UIKit.h>
@class MainProfileViewController;
@interface AuthenticationViewController : UIViewController
{
MainProfileViewController *mainProfileViewController;
}
@property (retain, nonatomic) IBOutlet UITextField *usernameTextField;
@end
#import "AuthenticationViewController.h"
#import "MainProfileViewController.h"
@interface AuthenticationViewController ()
@end
@implementation AuthenticationViewController
@synthesize usernameTextField;
- (IBAction)createAccount: (id)sender {
{
mainProfileViewController = [[MainProfileViewController alloc] init];
mainProfileViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
mainProfileViewController.userText.text = usernameTextField.text;
[self presentViewController:mainProfileViewController animated:YES completion:nil];
}
}
@end
#import <UIKit/UIKit.h>
#import "AuthenticationViewController.h"
@interface MainProfileViewController : UIViewController
{
UITextField *userText;
}
@property (retain, nonatomic) IBOutlet UILabel *resultLabel;
@property (retain, nonatomic) IBOutlet UITextField *userText;
@property (retain, nonatomic) NSString *textPass;
@end
#import "MainProfileViewController.h"
#import "AuthenticationViewController.h"
@interface MainProfileViewController ()
@end
@implementation MainProfileViewController
@synthesize resultLabel, userText, textPass;
- (void)viewDidLoad
{
userText.text = textPass;
[super viewDidLoad];
}
@end
【问题讨论】:
-
你必须传递字符串
标签: objective-c uiviewcontroller message-passing