---
title: "How to fit datepicker into UIActionSheet in iOS"  
description: "How to fit datepicker into UIActionSheet in iOS"  
author: "Tarun Kumar"  
published: 2015-12-14  
updated: 2015-12-15  
canonical: https://www.mindstick.com/forum/33732/how-to-fit-datepicker-into-uiactionsheet-in-ios  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# How to fit datepicker into UIActionSheet in iOS

I have created an applicaiton on iPhone, [now](https://yourviews.mindstick.com/view/81402/it-s-liberals-vs-progressives-in-us-politics-now) I want to fit UIDatePicker into the UIActionSheet. I have created a [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) to show actionSheet. Unfortunately it gets cropped off and the entire [Date Picker](https://www.mindstick.com/blog/627/date-picker-using-bootstrap-in-asp-dot-net) is not visible. I have not even attempted to [add](https://www.mindstick.com/forum/12983/add-address-in-textbox-when-page-is-load-and-if-i-search-address-in-textbox-show-in-map-by-javascript) the UIButton yet. Can [anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) suggest on getting the entire [view](https://yourviews.mindstick.com/view/84701/layoffs-in-google-india-2023-view) to fit properly? I'm not sure how to add the proper [dimensions](https://www.mindstick.com/forum/1834/c-sharp-xaml-how-to-modify-the-dimensions-of-the-rows-and-the-columns-of-a-grid) as UIActionSheet seems to lack an -initWithFrame: type constructor.

```
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:                                                    @"Date Picker"                                delegate:self                               cancelButtonTitle:@"Cancel"                               destructiveButtonTitle:nil                               otherButtonTitles:nil];// Add the pickerUIDatePicker *pickerView = [[UIDatePicker alloc] init];pickerView.datePickerMode = UIDatePickerModeDate;[actionSheet addSubview:pickerView];[actionSheet showInView:self.view];[pickerView release];[actionSheet release];
```

I also try with some other [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) like this:

```
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithFrame:CGRectMake(150.0, 150.0, 70.0f, 70.0f)];
```

The coords are ofcourse not realistic, but they don't seem to affect the position/[size](https://www.mindstick.com/forum/159799/how-can-you-manage-the-size-of-mdf-and-ldf-files) of the UIActionSheet.

## Replies

### Reply by Tarun Kumar

I get a solution of my code that I asked we can solve this like that:

```
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Date Picker"                                   delegate:self                         cancelButtonTitle:@"Cancel"                    destructiveButtonTitle:nil                         otherButtonTitles:nil];    // Add the picker    UIDatePicker *pickerView = [[UIDatePicker alloc] init];    pickerView.datePickerMode = UIDatePickerModeDate;    [actionSheet addSubview:pickerView];    [actionSheet showInView:self.view];     [actionSheet setBounds:CGRectMake(0,0,220, 400)];    CGRect pickerRect = pickerView.bounds;    pickerRect.origin.y = -100;    pickerView.bounds = pickerRect;    [pickerView release];    [actionSheet release];
```

But it will better to create a fullscreen view with a UIDatePicker and a navigation bar. For an example see UICatalog -> Pickers sample from the iPhone DevCenter.


---

Original Source: https://www.mindstick.com/forum/33732/how-to-fit-datepicker-into-uiactionsheet-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
