Brad
Brad

Reputation: 705

Why Is Bottom Half of Custom UIActionSheet with UIDatePicker Disabled?

Everything seems to be working great with my UIActionSheet that contains a UIDatePicker except that the bottom half of the DatePicker is disabled. Visually there is a shadow that makes the bottom half of the picker darker than the top half. Everything in the bottom half is disabled and I can't for the life of me figure out how to enable it.

I also noticed in my other "normal" UIActionSheets that just contain buttons, the bottom half of the cancel buttons are disabled.

This is the code for my custom UIActionSheet:

self.datePickerView = [[UIDatePicker alloc] init];
self.datePickerView.datePickerMode = UIDatePickerModeDate;

self.actionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose a Follow-up Date"
                   delegate:self cancelButtonTitle:nil 
                   destructiveButtonTitle:nil otherButtonTitles:@"Done", nil];

[self.actionSheet showInView:self.view];
[self.actionSheet addSubview:self.datePickerView];
[self.actionSheet sendSubviewToBack:self.datePickerView];
[self.actionSheet setBounds:CGRectMake(0,0,320, 500)];

CGRect pickerRect = self.datePickerView.bounds;
pickerRect.origin.y = -95;
self.datePickerView.bounds = pickerRect;

I've tried several things including sendSubviewToBack, BringSubviewToFront, etc but I have not had any luck. I appreciate your help!

Here is a screenshot. I added the red boxes for clarification. alt text http://gorgando.com/UIActionSheet%20Problem.png

Upvotes: 2

Views: 2238

Answers (2)

petert
petert

Reputation: 6692

Make sure you show your action sheet with the appropriate showXXX function - I had a similar problem when showing an action sheet from a UITabBar; so in this case used UIActionSheet method -showFromTabBar:.

Upvotes: 1

Reed Olsen
Reed Olsen

Reputation: 9169

Try setting the frame on your UIDatePicker instead of the bounds. I think you've got some weird stuff going on when you set the origin to -95 to position it.

Upvotes: 6

Related Questions