如何在iPhone App中更改AlertView的框架......?

时间:2011-02-16 11:57:50

标签: iphone

我想在AlertView上添加TextBox。但是当我添加时,它与按钮上的重叠很少......所以我想增加alertview的高度和宽度......可以有人说出任何想法吗?

2 个答案:

答案 0 :(得分:1)

请尝试以下代码:

UIAlertView alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Title", nil) 
                                                  message:NSLocalizedString(@"Message\n\n\n", nil)
                                                 delegate:self 
                                        cancelButtonTitle:NSLocalizedString(@"Cancel", nil)
                                        otherButtonTitles:NSLocalizedString(@"OK", nil), nil];

    UITextField textField = [[UITextField alloc] initWithFrame:CGRectMake(16.0, 100.0, 250.0, 25.0)];
    textField.borderStyle = UITextBorderStyleRoundedRect;

    [alertView addSubview:textField];
    [textField release];
    [alertView show];
    [alertView release];

答案 1 :(得分:0)

试试这个

UITextField *TextField = [[UITextField alloc] initWithFrame:CGRectMake(22.0, 50.0, 240.0, 30.0)];

 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Enter\n\n" message:@"" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil]; 
[alertView addSubview:TextField];
[alertView show];