ios - 弹出文本输入框

标签 ios objective-c uialertview

我想构建一个弹出警报 View ,允许用户输入文本。我尝试了下面的代码。

它可以工作,除了我需要一个更大的文本区域 - 比如 - UITextView。但是,当我使用具有更大框架区域的 UITextView 时。它覆盖了整个 UIAlertView 区域。

您有关于如何使用大文本区域(UITextView)构建弹出文本输入的示例吗?

 UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Preset Saving..." message:@"Describe the Preset\n\n\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
        UITextField *textField;
        textField = [[UITextField alloc] init];
        [textField setBackgroundColor:[UIColor whiteColor]];
        textField.delegate = self;
        textField.borderStyle = UITextBorderStyleLine;
        textField.frame = CGRectMake(15, 75, 255, 30);
        textField.font = [UIFont fontWithName:@"ArialMT" size:20];
        textField.placeholder = @"Preset Name";
        textField.textAlignment = UITextAlignmentCenter;
        textField.keyboardAppearance = UIKeyboardAppearanceAlert;
        [textField becomeFirstResponder];
        [alert addSubview:textField];

最佳答案

您是否正在研究类似 CODialog 的内容? 。我不确定它是否对您的具体情况有帮助,Apple 不赞成侵入 UIAlertView 的详细信息,因此不会有面向 future 的代码。

UIAlertView

The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.

关于ios - 弹出文本输入框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17253835/

相关文章:

ios - 带有文本字段的警报 View 在 iOS 中崩溃

ios - 在 UIView 上使用 CAGradientLayer 绘制渐变不起作用

ios - 如何在后台开始录制 iOS Audio Session ?

ios - 设置带有身份验证的URL的图像-IOS SDK

c++ - OSX 窗口捕获

ios - 使用多个图像和文本创建 UIAlertView

ios - 如何在 Swift 2.0 中从数组内部的数组中提取 JSON 数据

ios - [AppCommons respondsToSelector :]: message sent to deallocated instance

c++ - 在类语法帮助中比较对象;

ios - 如何在ipad应用程序的后台线程中显示UIAlertView?