title: How to prevent UIPickerView from closing when the user selects a field?
body: <p>I am trying to prevent my <code>UIPickerview</code> from closing when a field is selected by a user. I want the user to be able to select a field without <code>UIPickerview</code> dismissing automatically. I have tried so many things such as trying the following but none of them helped:</p>
  
  <pre><code>_txtfield.hidden=NO;
  [_pickerView endEditing:NO];
  [pickerView endEditing:NO];
  [_txtfield endEditing:NO];
  [self endEditing:NO];
  _pickerView.hidden=NO;
  </code></pre>
  
  <p>-----------------Here is more code----------------</p>
  
  <pre><code>  @implementation FieldWithPickerView {
      void(^pickerCallback)(NSInteger row);
      CGRect myFrame;
  
  
  }
  
  -(void)viewDidAppear{
  
  }
  
  -(void)commonInit:(CGRect)frame{
  
  
  
      [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
  
  
      [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[view]|" options:0 metrics:nil views:@{@"view":self.InputViewPicker}]];
      [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view]|" options:0 metrics:nil views:@{@"view":self.InputViewPicker}]];
      [self.layer setCornerRadius:10.0f];
      [self setClipsToBounds:YES];
  
  
      _pickerView = [[UIPickerView alloc] init];
      _pickerView.delegate=self;
  
  
  
  
      UIToolbar *toolBar=[[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
      [toolBar setTintColor:[UIColor grayColor]];
      UIBarButtonItem *doneBtn=[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(removePicker)];
      UIBarButtonItem *space=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
      [toolBar setItems:[NSArray arrayWithObjects:space,doneBtn, nil]];
      [self.txtfield setInputAccessoryView:toolBar];
  
  
  
      self.txtfield.inputView = _pickerView;
      [_txtfield.inputView setBackgroundColor:[UIColor clearColor]];
      [_txtfield setBackgroundColor:[UIColor clearColor]];
      _txtfield.text=@"--Select---";
  
  
      _label_view.textColor=[UIColor whiteColor];
  
      _label_view.backgroundColor=SECURUSBLUE;
      _label_view.textAlignment = NSTextAlignmentCenter;
  
      _txtfield.textAlignment = NSTextAlignmentCenter;
  
  
  
  
  }
  -(void)removePicker
  {
      [_txtfield resignFirstResponder];
  }
  
  -(void)pickerListenner:(void(^)(NSInteger row))handler
  {
      pickerCallback=handler;
  
  }
  
  - (id)initWithFrame:(CGRect)frame
  {
  //    NSLog(@"initwithframe picker");
  
      self = [super initWithFrame:frame];
      if (self)
      {
          [self commonInit:frame];
  
      }
      return self;
  }
  
  #pragma mark - Picker View Data source
  
  - (NSInteger)numberOfComponentsInPickerView:
  (UIPickerView *)pickerView
  {
      return 1;
  }
  
  - (NSInteger)pickerView:(UIPickerView *)pickerView
  numberOfRowsInComponent:(NSInteger)component
  {
      return [_pickerData count];;
  }
  
  - (NSString *)pickerView:(UIPickerView *)pickerView
               titleForRow:(NSInteger)row
              forComponent:(NSInteger)component
  {
      if(_pickerData.count == 0)
          return @"There is nothing";
      return [_pickerData objectAtIndex:row];
  }
  #pragma mark -
  
  #pragma mark - UIPickerViewDelegate
  - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
      // Code logic
      NSLog(@"selected row ---&gt;%ld!!!!",(long)row);
      pickerCallback(row);
  //    _txtfield.text=[_pickerData objectAtIndex:row];
  
      _txtfield.hidden=NO;
  
  
  }
  
  - (NSInteger)selectedRowInComponent:(NSInteger)component
  {
      return component;
  }
  </code></pre>