複数のテキストフィールドがあります。そのうちの 1 つで、UIPickerView を表示したいと考えています。私はこのようにしました:
-(void)showPicker{
[subject becomeFirstResponder];
actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
picker = [[UIPickerView alloc] initWithFrame:pickerFrame];
picker.showsSelectionIndicator = YES;
picker.dataSource = self;
picker.delegate = self;
[actionSheet addSubview:picker];
[picker release];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems: [NSArray arrayWithObject:@"Close"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissActionSheet) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
[closeButton release];
[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
}
-(void)dismissActionSheet{
[actionSheet dismissWithClickedButtonIndex:0 animated:YES];
}
閉じると、シートが閉じられますが、subject
textField のキーボードが表示されます。
今:
subject
そのtextFieldにキーボードを表示しないようにするにはどうすればよいですか?
キーボードを辞任する場所は次のとおりです。
- (void) resignKeyboard:(id)sender{
if ([name isFirstResponder])
[name resignFirstResponder];
else if ([email isFirstResponder])
[email resignFirstResponder];
else if ([message isFirstResponder])
[message resignFirstResponder];
else if ([subject isFirstResponder]) {
[subject resignFirstResponder];
}
}