title: A UIButton above a UIPickerView
body: <p>I have a UIPickerView which works correctly, now I want to add a button above it so that I can dismiss it.</p>
  
  <p>and here is my code where I initiate a UIPickerView as well as its dismiss button:</p>
  
  <pre><code>- (UIPickerView *)creatPickerView {
      UIPickerView *tempPickerView = [[[UIPickerView alloc] 
      initWithFrame:CGRectMake(kPickerViewX, kPickerViewY, kPickerViewWidth, kPickerViewHeight)] autorelease];
      tempPickerView.showsSelectionIndicator = YES;
      tempPickerView.delegate = self;
      tempPickerView.dataSource = self;
      UIButton *pickerButton = [[UIButton alloc] initWithFrame:CGRectMake(270, -32, 50, 32)];
      [pickerButton setBackgroundImage:[UIImage imageNamed:@"hidePicker.png"] 
           forState:UIControlStateNormal];
      [pickerButton addTarget:self action:@selector(hidePicker)   
           forControlEvents:UIControlEventTouchUpInside];
      [tempPickerView addSubview:pickerButton];
      [pickerButton release];
  
      [self.view addSubview:tempPickerView];
      return tempPickerView;
  }
  </code></pre>
  
  <p>and it works well on my iPhone 4.3 Simulator, like this:</p>
  
  <p><img src="https://i.stack.imgur.com/vGeDE.jpg" alt="enter image description here"></p>
  
  <p>apparently there is a button on the upper right of the pickerView,</p>
  
  <p>problem is, when I run the app in my device - a 5.0.1 iPhone4 and a 4.2.1 iTouch, the button is missed like it has never been added to the pickerView.</p>
  
  <p>Can anyone help me with this?</p>
  
  <p>Thanks a lot and a lot!</p>