title: UIPickerView with a Done button in Ipad
body: <p>I have faced one issue to display  <strong>UIPickerView with a Done</strong> button in Ipad.
  I done detailed researches though many links and blogs and got the suggestion as "display the UIPickerView from an <strong>UIActionSheet</strong>"</p>
  
  <p>I saw many posts related this, however there is no good answers.So please dont close it as a duplicate.</p>
  
  <p>Also i was able to get some good codes to do it and it worked fine in my Iphone devices.
  However i were found a difficulty in Ipad devices.
  The Action-Sheet is not displaying as a full view.
  Please see the below screenshot.this was the result!!!</p>
  
  <p><img src="https://i.stack.imgur.com/xDaOt.png" alt="UIPickerView with a Don button in Ipad"></p>
  
  <p>The code is used to do this is pasted below.</p>
  
  <pre><code>UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                                                      delegate:nil
                                                      cancelButtonTitle:nil
                                                      destructiveButtonTitle:nil
                                                      otherButtonTitles:nil];
  
  [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
  
  CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
  
  UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
  pickerView.showsSelectionIndicator = YES;
  pickerView.dataSource = self;
  pickerView.delegate = self;
  
  [actionSheet addSubview:pickerView];
  [pickerView 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)];
  </code></pre>
  
  <p>Then I have downloaded a excellent sample application from github through <a href="https://github.com/TimCinel/ActionSheetPicker" rel="nofollow noreferrer">sample pickers</a></p>
  
  <p>After the download, i have copied the classes only mandatory for me to my application.</p>
  
  <p>The method they are using to show the UIPickerView+Done button through Action-Sheet is described below</p>
  
  <pre><code>ActionStringDoneBlock done = ^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) {
  
          if ([myLabel respondsToSelector:@selector(setText:)]) {
              [myLabel performSelector:@selector(setText:) withObject:selectedValue];
          }
      };
  
      ActionStringCancelBlock cancel = ^(ActionSheetStringPicker *picker) {
  
          NSLog(@"Block Picker Canceled");
      };
  
      NSArray *colors = [NSArray arrayWithObjects:@"Red", @"Green", @"Blue", @"Orange", nil];//picker items to select
  
  
      [ActionSheetStringPicker showPickerWithTitle:@"Select a Block" rows:colors initialSelection:0 doneBlock:done cancelBlock:cancel origin:myButton];
  </code></pre>
  
  <p>In the last line of code they have used the parameter as <strong>origin:</strong> and we can pass any objects (button,label etc) to it.</p>
  
  <p>The Action-sheet will take origin as the passed object.</p>
  
  <p>Here my issue came again :). I have used <strong><em>segment control</em></strong> to pick the time as per my conditions.</p>
  
  <p>if i give mySegment as the origin parameter,the Action-sheet origin arrow will display from middle of my segment control.Not from the selected tab ,which is too bad and will give confusion to my valuable users.</p>
  
  <p>So i have added individual labels under the segment sections and given it for the origin parameter of the mentioned method and i fixed my issue.</p>
  
  <p>However i know its not a good fix :)</p>
  
  <p>May i know is there any easy way to do it? </p>
  
  <p><strong>Is Apple support ActionSheet+UIPickerView+DoneButton in Ipad</strong>?</p>
  
  <p>Any help on this issue is Appreciated</p>