我正在尝试显示一个基于警报窗口中的OK按钮的UITextField。因此,当用户按下OK按钮时,会出现另一个文本框,用户可以在其中输入配置文件名称。然而,根据下面的代码,我看到在点击OK之后,它继续说"No profile name specified“,因为它发现profile.txt是空的。下面是一段代码,它显示弹出警报,提示用户使用配置文件名称保存配置文件。
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello, User ! Save Profile" message:@"Provide a profile Name" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK" ,nil];
profileName = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 2600.0, 25.0)];
[profileName setBackgroundColor:[UIColor whiteColor]];
[alert addSubview:profileName];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 130.0);
[alert setTransform:myTransform];
[alert show];
[alert release];
感谢您的回复!
提前感谢!
发布于 2014-09-11 14:04:28
我能够让它在iOS7上工作,
alert.alertViewStyle = UIAlertViewStylePlainTextInput;profileName = alert textFieldAtIndex:0;
谢谢
https://stackoverflow.com/questions/25788280
复制