Lor*_*man 1 xcode ios alertview
如何在alertview中添加文本字段?我正在尝试做一个应用程序,在应用程序提交编辑之前,用户必须通过在所述alertview上键入他/她的密码来验证第一,但我该怎么做?似乎我搜索的代码不再起作用了.这里是:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Log In" message:@"Please enter your Password" delegate:self cancelButtonTitle:@"Log In" otherButtonTitles:@"Cancel", nil];
[alert addTextFieldWithValue:@"" label:@"Password"];
UITextField *tf = [alert textFieldAtIndex:0];
tf.clearButtonMode = UITextFieldViewModeWhileEditing;
tf.keyboardType = UIKeyboardTypeAlphabet;
tf.keyboardAppearance = UIKeyboardAppearanceAlert;
tf.autocapitalizationType = UITextAutocapitalizationTypeWords;
tf.autocapitalizationType = UITextAutocorrectionTypeNo;
Run Code Online (Sandbox Code Playgroud)
错误说
"No visible @interface for 'UIAlertView'
declares the selector 'addTextFieldWithValue:label:'"
on the [alert addTextFieldWithValue:@"" label:@"Password"];
Run Code Online (Sandbox Code Playgroud)
我还想问一下如何将代码放在alertview上的Confirm按钮上.
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
Run Code Online (Sandbox Code Playgroud)
或者如果您需要它是安全的(用于密码)
alert.alertViewStyle = UIAlertViewStyleSecureTextInput;
Run Code Online (Sandbox Code Playgroud)
编辑:
我不是100%肯定你的意思是"把代码放在确认按钮上",但如果你想知道他们是推送确认还是取消,你只需要实现
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
//check the button index and do something if it's the right one.
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2154 次 |
| 最近记录: |