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 に答える