UIAlertView定制,如何管理标准按钮?

时间:2011-06-13 10:53:04

标签: iphone button uitextfield uitextview uialertview

我自定义UIAlertView并添加UITextViewUITextfield,但我需要设置按钮(我在标准init中添加按钮)到{{1}的底部查看。在UIAlertView init我添加消息UIAlertView时,这会给我5个字符串,但当我添加另一个@"\n\n\n\n\n"时,会显示它的标准文本视图。 看看图像,让我更清楚地了解我拥有什么和我需要什么。 enter image description here

1 个答案:

答案 0 :(得分:0)

使用此示例....

 // Create Alert
    UIAlertView* av = [UIAlertView new];
    av.title = @"Find";
    // Add Buttons
    [av addButtonWithTitle:@"Cancel"];
    [av addButtonWithTitle:@"Find & Bring"];
    [av addButtonWithTitle:@"Find & Go"];
    [av addButtonWithTitle:@"Go to Next"];
    // Make Space for Text View
    av.message = @"\n";
    // Have Alert View create its view heirarchy, set its frame and begin bounce animation
    [av show];
    // Adjust the frame
    CGRect frame = av.frame;
    frame.origin.y -= 100.0f;
    av.frame = frame;
    // Add Text Field
    UITextField* text = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
    text.borderStyle = UITextBorderStyleRoundedRect;
    [av addSubview:text];
    [text becomeFirstResponder];