gpt4 book ai didi

ios - 由于添加了文本字段,警报 View 向上移动

转载 作者:行者123 更新时间:2023-11-29 03:49:58 25 4
gpt4 key购买 nike

我正在通过单击按钮创建警报 View 。我在其中放置了一个 UITextfield。但警报 View 在屏幕中向上移动。我无法将其带回屏幕中央。

这是我的代码和屏幕截图。
enter image description here

创建此警报 View 的代码是这样的:-

- (IBAction)btn_cancelAppointment_click:(id)sender
{
// Here We are Creating Alertview which asks for
UIAlertView* cancelAlert = [[UIAlertView alloc] init];

[cancelAlert setDelegate:self];
[cancelAlert setTitle:@"Are you sure you want to request cancellation of this appointment?"];
[cancelAlert setMessage:@" "];
[cancelAlert addButtonWithTitle:@"NO"];
[cancelAlert addButtonWithTitle:@"YES"];

UITextField * txt_cancelNote = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 88.0, 245.0, 30.0)];

[txt_cancelNote setBackgroundColor:[UIColor whiteColor]];
[txt_cancelNote setBorderStyle:UITextBorderStyleRoundedRect];
[txt_cancelNote setPlaceholder:@"Enter cancellation note"];
txt_cancelNote.tag = 11;

[cancelAlert addSubview:txt_cancelNote];
cancelAlert.delegate = self;
[cancelAlert show];
}

所以,如果有人能告诉我如何将其带回屏幕中央。任何帮助将不胜感激。

最佳答案

尝试设置UIAlertViewtransform属性

  UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Test" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
alertView.transform = CGAffineTransformMakeTranslation(x, y);

关于ios - 由于添加了文本字段,警报 View 向上移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17170296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com