我正在单击按钮创建警报视图。我在其中放置了一个 UITextfield。但是警报视图在屏幕上向上移动。我无法将它带回屏幕中央。
这是我的代码和屏幕截图。
创建此警报视图的代码是这样的:-
- (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];
}
所以,如果有人能告诉我如何把它带回屏幕的中心。任何帮助将不胜感激。