【发布时间】:2014-08-15 18:50:01
【问题描述】:
我的一些ViewController.h
NSString *title1;
NSString *sub1;
@interface MapMain : UIViewController
{
IBOutlet UIButton *setter;
}
都在同一个ViewController.m
-(IBAction)Write:(id)sender
{
[self alertView];
}
-(void)alertView
{
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@""
message:@"Your Info"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Done", nil];
alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
UITextField * alertTextField1 = [alert textFieldAtIndex:0];
alertTextField1.keyboardType = UIKeyboardTypeDefault;
alertTextField1.placeholder = @"Name";
UITextField * alertTextField2 = [alert textFieldAtIndex:1];
alertTextField2.keyboardType = UIKeyboardTypeDefault;
alertTextField2.placeholder = @"Username";
alertTextField2.secureTextEntry = NO;
[alert show];
}
因此,当我单击特定按钮时,此代码正确地使弹出窗口出现两个文本字段。如何将用户在按下“完成”按钮时输入的文本分别存储到我的NSString *title1 和NSString *sub1 中,以便以后按下其他按钮时可以使用字符串值。当用户按下“取消”按钮时,如何让我的程序不存储文本?
【问题讨论】:
标签: ios nsstring uitextfield uialertview