文本输入弹出框

时间:2013-06-22 18:11:55

标签: ios objective-c uialertview

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

它的工作除外,我需要一个更大的文本区域 - 比如 - 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];

1 个答案:

答案 0 :(得分:1)

你有没有找到像CODialog这样的东西。我不确定它是否可以在您的确切情况下提供帮助,因为苹果不赞成UIAlertView的细节,所以不会有面向未来的代码。

UIAlertView

  

UIAlertView类旨在按原样使用,不支持子类化。 此类的视图层次结构是私有的,不得修改。