2 つのテキスト フィールドがあるビューを実装しました。最初のテキスト フィールドで、ユーザーがクリックすると、ピッカー ビューが表示されます。ユーザーが他のテキスト フィールド キーボードをクリックすると、キーボードが表示されます。ただし、ユーザーが 2 番目のテキスト フィールドから最初のテキスト フィールドに移動すると、キーボードが表示され、このキーボードの背面にピッカー ビューがあります。ユーザーがキーボードの完了ボタンを押さずに 2 番目のテキストフィールドから最初のテキストフィールドに移動すると、このキーボードを辞任できません。
-(void)textFieldDidBeginEditing:(UITextField *)myTextField
{
if(myTextField == firsttextfield)
{
[firsttextfield resignFirstResponder];
medicationtypepicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0,190,320,215)];
medicinetypearray = [[NSMutableArray alloc]initWithObjects:@"Capsules",@"Eyedrops",
@"Eardrops",@"Nosedrops",@"Inhaler",@"Syrup",@"Injections",@"Oils",@"Ointment", nil];
medicationtypepicker.delegate = self;
medicationtypepicker.showsSelectionIndicator = YES;
medicationtypepicker.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:medicationtypepicker];
}
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[secondtextfield resignFirstResponder];
return YES;
}
誰かがキーボードを却下する考えを持っている場合。解決策を提供してください。
どうもありがとうございました。