我在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];
}
}问题是动作单被激活了,但是键盘没有被隐藏起来!
发布于 2012-12-14 13:39:46
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;
}https://stackoverflow.com/questions/13861326
复制相似问题