gpt4 book ai didi

ios - iphone:键盘没有隐藏

转载 作者:行者123 更新时间:2023-11-28 19:24:12 24 4
gpt4 key购买 nike

我有一种情况,我有一个警报 View ,其中以编程方式绘制了一个文本字段

UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"Welcome" message:@"Enter you name" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];

[nameField setBorderStyle:UITextBorderStyleRoundedRect];
[nameField setPlaceholder:@"Enter Owners name"];
[nameField setTextAlignment:UITextAlignmentCenter];
[nameField setDelegate:self];
[nameField setBackgroundColor:[UIColor clearColor]];

[alertView addSubview:nameField];
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0, -80.00);
[alertView setTransform: moveUp];

[alertView show];
[alertView release];

为了隐藏我用过的键盘

- (BOOL)textFieldShouldReturn:(UITextField *)textField{

[textField resignFirstResponder];
return YES;

但键盘没有隐藏。请帮助我。

最佳答案

您可以使用它隐藏您的键盘。单击您的模拟器/仿真器/iOS 设备的背景时,这将起作用。

  -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

[yourtextfield resignFirstResponder];

// you can have multiple textfields here


}

关于ios - iphone:键盘没有隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5857313/

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