我有一個應用程序,其中有2個文本框。現在我的問題是,讓我們說第一個用戶點擊普通文本框。哪個會彈出鍵盤。然後,不選擇完成按鈕,他點擊日期字段。這將彈出操作表(不關閉鍵盤)。隱藏操作表後,用戶必須點擊其他文本字段並單擊鍵盤上的返回鍵。如果操作表要彈出,請隱藏鍵盤
如果操作表要彈出,我想隱藏鍵盤?
我的代碼如下
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
if([textField isEqual:txtdob])
{
[textField resignFirstResponder];
actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
// txtdob.inputView=actionSheet;
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
datepicker=[[UIDatePicker alloc] initWithFrame:pickerFrame];
datepicker.datePickerMode = UIDatePickerModeDate;
//[datepicker setMinimumDate:minDate];
[datepicker addTarget:self action:@selector(changeDateInLabel:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:datepicker];
[datepicker release];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Done"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blueColor];
[closeButton addTarget:self action:@selector(dismissActionSheet) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
[closeButton release];
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
}
}
遺憾它沒有爲我的作品。 –