touchesBegan pas être appelé

Je suis en utilisant un UIPicker pour remplir un objet UITextField au lieu d'un clavier. Cela fonctionne très bien mais je ne peux pas fermer la UIPicker maintenant. Je veux être capable de toucher n'importe où sur l'écran et fermer la UIPicker. J'ai essayé de chacune des touches de la méthode aucun ne le feu.

setUserInteractionEnabled:OUI.
Vous ne savez pas si cela fait une différence, mais je suis en utilisant une table de montage

Si j'ai mis quelque chose dans mon AppDelegate pour écouter touche?

Voici mon .h

 #import <UIKit/UIKit.h>

@interface RNMemberTableViewController : UITableViewController<UIPickerViewDataSource, UIPickerViewDelegate, UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UIPickerView *behaviorPicker;
@property (nonatomic, weak) IBOutlet UIDatePicker *dateOfRecordPicker;
@property (nonatomic, strong) NSArray *behaviorLevels;
@property (weak, nonatomic) IBOutlet UITextField *behaviorTextField;

@end

ici une partie de la mise en œuvre...

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view setUserInteractionEnabled:YES];
    [self buildBehaviorPicker];
    NSLog(@"Member View");
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"test");
    [self.view touchesBegan:touches withEvent:event];
    UITouch *touch = [touches anyObject];
    int tCount = touch.tapCount;
    NSLog(@"Touched %d", tCount);
}

- (void) buildBehaviorPicker
{
    behaviorLevels = [[NSArray alloc] initWithObjects:@"Unsatisfactory", @"Needs Improvement", @"Satisfactory", @"Outstanding", nil];

    UIPickerView *pickerView = [[UIPickerView alloc] init];
    pickerView.dataSource = self;
    pickerView.delegate = self;
    [pickerView selectRow:2 inComponent:0 animated:NO];
    self.behaviorTextField.inputView = pickerView;


}

Merci d'avance
-Bob

  • Bob, si vous avez aimé le travail de répondre à la marquer comme "répondu" en conséquence.
InformationsquelleAutor Bob | 2014-07-07