我有四个 Uitextfields,在一个文本字段上我设置了操作表和三个仅用于文本输入的其他字段。这是我的代码..
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
if(textField.tag==3)// tag will be integer
{
NSLog(@"ACTION SHEET WILL DISPLAY");
[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;
}
-(BOOL)textFieldShouldReturn:(UITextField*)textField {
if (textField.tag) {
UIResponder *nextField = [textField viewWithTag:(textField.tag + 1)];
[nextField becomeFirstResponder];
}
else {
// Unknown field, just resign first responder.
[textField resignFirstResponder];
}
return NO;
}
现在我的问题是,当我从三个文本字段中的任何一个按键盘 TAB 键时,会显示我的操作表!,但如果我单独单击文本字段,它工作得很好。