我正在textFieldDidBeginEditing
上显示操作表,这是我的代码:
- (void)textFieldDidBeginEditing:(UITextField *)textField {
// dept_label is my UITextField property
if (textField == dept_label) {
[textField setUserInteractionEnabled:YES]; // i also used dept_label instead textfield here...
[textField resignFirstResponder];
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select"
delegate:self
cancelButtonTitle:@"OK"
destructiveButtonTitle:nil
otherButtonTitles:@"Manpower", @"Admin",@"Research" ,nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleDefault];
[actionSheet showInView:self.view];
}
}
问题是操作表被激活但键盘没有被隐藏!
答案 0 :(得分:0)
像这样使用UITextField
委托:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
if (textField == dept_label) {
// dept_label is my UITextField property
[textField setUserInteractionEnabled:YES];
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select"
delegate:self
cancelButtonTitle:@"OK"
destructiveButtonTitle:nil
otherButtonTitles:@"Manpower", @"Admin", @"Research", nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleDefault];
[actionSheet showInView:self.view];
return NO;
}
return YES;
}
答案 1 :(得分:0)
finally this worked..
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
if(textField==dept_label){
[textField setUserInteractionEnabled:YES];
[textField resignFirstResponder];
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select" delegate:self cancelButtonTitle:@"OK" destructiveButtonTitle:nil otherButtonTitles:@"Manpower", @"Admin",@"Research" ,nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
}
return YES;
}