gpt4 book ai didi

ios - 如何将文本字段添加到警报 View ? Xcode 4.5 iOS6

转载 作者:行者123 更新时间:2023-12-01 17:23:25 26 4
gpt4 key购买 nike

如何将文本字段添加到Alertview?我正在尝试制作一个应用,其中在该应用提交编辑之前,用户必须通过在所述Alertview上键入其密码来对1st进行身份验证,但是我该怎么做?似乎我搜索过的代码不再起作用。这里是:

  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;

错误说
 "No visible @interface for 'UIAlertView' 
declares the selector 'addTextFieldWithValue:label:'"
on the [alert addTextFieldWithValue:@"" label:@"Password"];

我也想问一下如何将代码放在Alertview的Confirm按钮上。

最佳答案

alert.alertViewStyle = UIAlertViewStylePlainTextInput;

或者如果您需要安全的密码(用于密码)
alert.alertViewStyle = UIAlertViewStyleSecureTextInput;

编辑:

我不确定100%表示“将代码放入确认按钮”的意思,但是如果您想知道他们是否按下了确认或取消,则只需实施
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
//check the button index and do something if it's the right one.
}

关于ios - 如何将文本字段添加到警报 View ? Xcode 4.5 iOS6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14617455/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com