gpt4 book ai didi

ios - 如果要弹出操作表,则隐藏键盘

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

我有一个应用程序,其中有 2 个文本字段。现在我的问题是,假设第一个用户点击普通文本字段。这将弹出键盘。然后,他没有选择“完成”按钮,而是点击了日期字段。这将弹出操作表(无需关闭键盘)。隐藏操作表后,用户必须点击其他文本字段并单击键盘的返回键。

如果要弹出操作表,我想隐藏键盘吗?

我的代码如下

- (void)textFieldDidBeginEditing:(UITextField *)textField
{


if([textField isEqual:txtdob])
{

[textField resignFirstResponder];


actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
// txtdob.inputView=actionSheet;
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);

datepicker=[[UIDatePicker alloc] initWithFrame:pickerFrame];
datepicker.datePickerMode = UIDatePickerModeDate;
//[datepicker setMinimumDate:minDate];
[datepicker addTarget:self action:@selector(changeDateInLabel:) forControlEvents:UIControlEventValueChanged];

[actionSheet addSubview:datepicker];
[datepicker release];

UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Done"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blueColor];
[closeButton addTarget:self action:@selector(dismissActionSheet) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
[closeButton release];

[actionSheet showInView:self.view];

[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];

}
}

最佳答案

在你的 ViewController 中调用它

[self.view endEditing:NO];

关于ios - 如果要弹出操作表,则隐藏键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7379179/

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