-1

我有显示带有长消息的 uialertview 的代码:

alert = [[UIAlertView alloc] initWithTitle:@"looong text" message:@"text to loong" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField *myTextField = [alert textFieldAtIndex:0];
myTextField.delegate = self;
[alert show];   
alert.frame = CGRectMake(
    alert.frame.origin.x,
    alert.frame.origin.y - 50,
    alert.frame.size.width, 
    300);

但我得到:

这反而

4

2 回答 2

4

即使在文档中,您也不应该弄乱UIAlertView它。

子类化注释

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

更好的选择它来创建您自己的视图并显示它。

于 2014-02-06T14:49:55.097 回答
0

I added this code to my class. And it work good for me

-(void)willPresentAlertView:(UIAlertView *)alertView {
    if(alertView.tag == ZIP_CODE_TAG){
    if ([[[UIDevice currentDevice] systemVersion] floatValue] <7)
    {
        NSArray *subviewArray = [alertView subviews];
        UILabel *message = (UILabel *)[subviewArray objectAtIndex:2];
        message.lineBreakMode = UILineBreakModeWordWrap;
        message.numberOfLines = 0;
        [message setFrame:CGRectMake(10, 95, 260, 100)];

        UIButton *okbutton = (UIButton *)[subviewArray objectAtIndex:3];
        [okbutton setFrame:CGRectMake(10, 240, 260, 42)];

        UIButton *cancelbutton = (UIButton *)[subviewArray objectAtIndex:4];
        [cancelbutton setFrame:CGRectMake(10, 287, 260, 42)];

        UITextField *textfield = (UITextField *)[subviewArray objectAtIndex:5];
        [textfield setFrame:CGRectMake(10, 198, 260, 50)];

        UITextField *placeTF = (UITextField *)[subviewArray objectAtIndex:6];
        [placeTF setFrame:CGRectMake(15, 188, 256, 50)];
    }
}

}

于 2014-04-08T14:19:14.427 回答