我用 3 个 UITextField 创建了简单的 gui
添加了一个按钮,当单击提交时,对于测试我打印了 3 个文本值......我在每个字段的文本框中输入......我在这里错过了什么?在提交之前我应该把它保存到移动设备的磁盘上吗?
IOS 5.0 测试版
#import <UIKit/UIKit.h>
@interface CloudClientViewController : UIViewController
{
@private
UITextField *usernameData;
UITextField *passwordData;
UITextField *ngccData;
UIButton *submitButton;
}
@property (nonatomic,retain) IBOutlet UITextField *usernameData;
@property (nonatomic,retain) IBOutlet UITextField *passwordData;
@property (nonatomic,retain) IBOutlet UITextField *ngccData;
@property (nonatomic,retain) UIButton *submitButton;
-(IBAction)submitButton:(id)sender;
@end
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
/*
Allocting memory for the username password and the ngcc server
*/
usernameData = [[UITextField alloc]init];
passwordData = [[UITextField alloc]init];
ngccData = [[UITextField alloc]init];
}
-(IBAction)submitButton:(id)sender
{
NSLog(@"The value that was entered to usernameData is: %@",usernameData.text);
NSLog(@"The value that was entered to passwordData is: %@",passwordData.text);
NSLog(@"The value that was entered to ngccData is: %@",ngccData.text);
}
现在当 gui 提示时,我只是在 UITextField 字段中输入 test 作为字符串并单击提交,我希望将测试字符串视为值,而不是看到 null。
想法?
GNU gdb 6.3.50-20050815(Apple 版本 gdb-1705)(2011 年 7 月 5 日星期二 07:28:08 UTC)版权所有 2004 Free Software Foundation, Inc. GDB 是自由软件,受 GNU 通用公共许可证保护,您是欢迎在某些条件下更改和/或分发它的副本。键入“显示复制”以查看条件。GDB 绝对没有任何保证。键入“显示保修”以获取详细信息。此 GDB 配置为“x86_64-apple-darwin”。sharedlibrary apply-load-rules all 附加到进程 10248。2011-07-27 16:52:56.235 CloudClient[10248:207] 输入到 usernameData 的值是: (null) 2011-07-27 16:52:56.237 CloudClient[10248:207] 输入到 passwordData 的值为: (null) 2011-07-27 16:52:56.238 CloudClient[10248:207] 的值输入到 ngccData 是:(null)