1
votes

so I've spent an ungodly amount of time trying to create a Date Picker Action Sheet (so it looks better than a regular full screen view) and it just does not want to load in the right place. Currently, the action sheet pops up with about 25% (maybe just the height of the tab bar) clipped.

I've taken a look at almost every StackOverflow topic I could find, which means I've tried creating a pointer to my appdelegate and performing showInView:[[appdelegate window] view] as well as showFromTabBar:[self tabBarController] tabBar and showFromTabBar[self parentViewController] tabBarController] tabBar]. Every permutation of showInView or showFromTabBar results in the date picker being shifted down approximately the height of the tab bar.

Just to clarify, the view that I am launching the Action Sheet from is a view within a nav bar within a tab bar.

UIActionSheet *dateSheet = [[UIActionSheet alloc] initWithTitle:@"Action Sheet Message"
                                                       delegate:self
                                              cancelButtonTitle:@"nil
                                         destructiveButtonTitle:@nil 
                                              otherButtonTitles:nil];

UIDatePicker *datePicker = [[[UIDatePicker alloc] init] autorelease];
[dateSheet addSubview:datePicker];
[dateSheet showFromTabBar:[[self tabBarController]tabBar]];
[dateSheet release];

If anyone could give me an idea of what I'm doing wrong, it would be highly appreciated.

Thanks.

1
Have you tried initing your datepicker with initWithFrame initializer? I think this way you can place your datepicker wherever you want.Mikayil Abdullayev
No, I haven't tried that yet... I'll look into that. ThanksHarry Lucas
I just attempted to use CGRect and initWithFrame... I was able to get the date picker in the right location by changing the y-value to a negative value but now I can't select the date picker at all... really stumped hereHarry Lucas
Do you mean the datpicker is like disabled?Mikayil Abdullayev

1 Answers

0
votes

Usually the UIActionSheet object calculates its height based on the buttons it has to show which in your case is none. So its height is minimal and you see only part of the subview (datePicker). The workaround would be to declare an appropriate frame like this,

[dateSheet addSubview:datePicker];
[dateSheet showFromTabBar:[[self tabBarController]tabBar]];
[dateSheet setFrame:appropriateFrame];
[dateSheet release];

Check what the correct values for the appropriateFrame are and use them. Animation to its spot from the bottom will be taken care of.