0

我正在显示操作表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];
    }
}

问题是操作表被激活但键盘没有被隐藏!

4

2 回答 2

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;
}
于 2012-12-13T14:16:27.383 回答
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;      
}
于 2012-12-14T05:39:45.690 回答