views:

94

answers:

3

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

+1  A: 

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.

Reed Olsen
A: 

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

petert
Thanks for the suggestion. I just now tried this [self.actionSheet showFromTabBar:self.tabBarController.tabBar]; instead of my previous [self.actionSheet showInView:self.tabBarController.view]; I got exactly the same result. I think the problem must have to do with the UIActionSheet itself blocking that bottom portion from allowing user interaction.
Gorgando
I re-read you're question. You're far better off adding your date picker etc. to a UIView and manually animating this up and down from the bottom of the screen. I never had success with UIActionSheet used in this manner. Don't think Apple would suggest it either.
petert
I did what you suggested with a UIView. Thanks!
Gorgando
Good. This was the blog which pushed me in the right direction: http://ramin.firoozye.com/2009/09/29/semi-modal-transparent-dialogs-on-the-iphone/
petert
A: 

Gorgando, How did you solve this issue? I am encountering the same exact behavior... Thanks heaps.

pettaiphone
I ended up creating a new view with the datepicker on it. When it needs to be displayed, I animate the view moving up the way the Action Sheet works, but I'm not using an Action Sheet.
Gorgando
Have you done this way? http://ramin.firoozye.com/2009/09/29/semi-modal-transparent-dialogs-on-the-iphone/
pettaiphone
Could you provide a code snippet PLEASE?
pettaiphone