gpt4 book ai didi

objective-c - 如何在消息框 objective-c 中显示文本框

转载 作者:行者123 更新时间:2023-12-02 05:40:02 26 4
gpt4 key购买 nike

当用户按下主 Storyboard 中的按钮时,我想显示包含标签和文本框以及确定按钮和取消按钮的消息框,并在用户按下 IOS 上的确定后获取文本框中的字符串?

我知道如何显示错误消息或类似的东西,但我不知道如何显示那样的消息框?

最佳答案

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Save"
message:@"Enter File Name"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];

alertView.alertViewStyle = UIAlertViewStylePlainTextInput;

[alertView show];



- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"Alert View dismissed with button at index %d",buttonIndex);

switch (alertView.alertViewStyle)
{
case UIAlertViewStylePlainTextInput:
{
UITextField *textField = [alertView textFieldAtIndex:0];
NSLog(@"Plain text input: %@",textField.text);
}
break;

case UIAlertViewStyleSecureTextInput:
{
UITextField *textField = [alertView textFieldAtIndex:0];
NSLog(@"Secure text input: %@",textField.text);
}
break;

case UIAlertViewStyleLoginAndPasswordInput:
{
UITextField *loginField = [alertView textFieldAtIndex:0];
NSLog(@"Login input: %@",loginField.text);

UITextField *passwordField = [alertView textFieldAtIndex:1];
NSLog(@"Password input: %@",passwordField.text);
}
break;

default:
break;
}
}

关于objective-c - 如何在消息框 objective-c 中显示文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11128724/

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