0

这对我来说很好用

当进入横向模式时为什么这是拉伸

我该如何解决这个问题。我正在以编程方式添加此文本字段。见下面的代码

AppDelegate * delegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];



    delegate.alert=[[UIAlertView alloc]initWithTitle:@"Password" message:@"\n\n\n\n\n" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];


    delegate.lbl=[[UILabel alloc]init];
    delegate.lbl.frame=CGRectMake(60, 42, 200, 18);

    delegate.lbl.backgroundColor=[UIColor clearColor];
    [delegate.alert addSubview:delegate.lbl];

    delegate.lbl.text=@"Please enter the pwd";
    delegate.lbl.textColor=[UIColor grayColor];


    CGRect rect = {70, 70, 140, 30};
    delegate.txtfield1 = [[UITextField alloc] initWithFrame:rect];
    delegate.txtfield1.backgroundColor = [UIColor whiteColor];
    delegate.txtfield1.placeholder=@" Password";

    delegate.txtfield1.borderStyle = UITextBorderStyleRoundedRect;


    delegate.txtfield1.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;

    delegate.txtfield1.delegate=self;
    delegate.txtfield1.secureTextEntry=YES;

    [delegate.alert addSubview:delegate.txtfield1];

    /*delegate.txtfield1.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin;*/

    CGRect rect1 = {70, 110, 140, 30};
    delegate.txtfield2=[[UITextField alloc]initWithFrame:rect1];
    delegate.txtfield2.backgroundColor = [UIColor whiteColor];

    delegate.txtfield2.placeholder=@" Confirm pwd";
    delegate.txtfield2.delegate=self;
    delegate.txtfield2.secureTextEntry=YES;


    delegate.txtfield2.borderStyle=UITextBorderStyleRoundedRect;

    delegate.txtfield2.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;

    [[delegate.txtfield2 layer]setBorderColor:[[UIColor blackColor]CGColor]];
    [[delegate.txtfield2 layer]setBorderWidth:1.5];
    [[delegate.txtfield2 layer]setCornerRadius:3];

    [delegate.alert addSubview:delegate.txtfield2];


    delegate.SaveButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    delegate.SaveButton.frame = CGRectMake(12, 150, 110, 40);
    [delegate.SaveButton setTitle:@"Save" forState:UIControlStateNormal];


    [delegate.SaveButton addTarget:self action:@selector(Save) forControlEvents:UIControlEventTouchUpInside];

    [delegate.alert addSubview:delegate.SaveButton];


    delegate.CancelButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    delegate.CancelButton.frame=CGRectMake(160, 150, 110, 40);

    [delegate.CancelButton setTitle:@"Cancel" forState:UIControlStateNormal];


    [delegate.CancelButton addTarget:self action:@selector(Cancel) forControlEvents:UIControlEventTouchUpInside];

    [delegate.alert addSubview:delegate.CancelButton];

    [delegate.alert show];
4

1 回答 1

0

只需从您的代码“\n\n\n\n\n”中删除它即可UITextView
编辑

您必须为此制作自己的自定义警报。

于 2013-06-27T07:00:38.583 回答