我对这方面真的很陌生。我一直在努力学习一些“HelloWorld”类型的教程,它们基本上有一个文本字段和一个按钮,当你点击按钮时,它会提醒文本字段中的任何内容。我已经得到了一个警报显示,能够直接设置标题,消息和按钮文本。但是,我获取UITextField内容的尝试一直失败。我要么得到错误,没有响应,要么只是“(null)”。我的密码在这里。
@synthesize textField;
- (IBAction)btnClicked:(id)sender {
//text of textField
NSString *str = [[NSString alloc] initWithFormat:@"Hello, %@", textField.text];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello!"
message:str delegate:self
cancelButtonTitle:@"Done"
otherButtonTitles:nil];
[alert show];
[alert autorelease];
}