iphone - weird bug between UIActionSheet and UITabBar - iphone

In my tabbar app, i bring up a UIActionsheet from an action, called from a button in a navigation controller title bar.
The UIActionsheet functions as per normal, except for the bottom half of the below button 'cancel', which strangely doesnt respond to touch in the iPhone Simulator. The bottom half of the cancel button is where the UITabBar lies behind, and therefore is probably the problem.
Any ideas?
alt text http://img12.imageshack.us/img12/2166/screenshot20100119at236.png
Solution
My solution was from the first answer. Here is my working example code
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:message delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:#"OK" otherButtonTitles:nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
[actionSheet release];

This looks like an UIActionSheet to me...
Anyway, you should show the action sheet as a subview of the application window, not of the current view.
UIActionSheet *actionSheet = [[UIActionSheet alloc] init...];
// ...
[actionSheet showInView:[UIApplication sharedApplication].keyWindow];

Related

ios UIActionSheet cancel button doesn't work right

I have this problem:
here is my code:
UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:#"Share the race" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:#"Send with mail" otherButtonTitles:nil];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[popupQuery showInView:self.view];
[popupQuery release];
and everything seems ok, the 2 buttons are showed right, the "send with mail" button is ok, but the cancel catch the click only on the upper side...
here a shot that illustrate the situation:
how can I solve this?
thanks:)
My guess is that the bottom portion of the UIActionSheet extends beyond the bounds of the view, and so doesn't respond to touches.
To test this theory, add another button and see if all upper buttons work fine but the bottom button still exhibits this behavior.
To fix this problem, make sure the view extends to the bottom of the screen. If you have a tabBar in your app, that's going to be my suspect for the problem. You could use showFromTabBar: if you want the sheet above the tabBar, or showFromToolbar: to show it from a toolBar.
If you don't have a bottom bar, then I'm wrong and have no idea.
You should show the action sheet as a subview of the application window, not of the current view.
UIActionSheet *actionSheet = [[UIActionSheet alloc] init...];
// ...
[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
May be it will help others.
Happy Coding :)
use
[actionSheet showFromTabBar:[[self tabBarController] tabBar]];
instead of
[actionSheet showInView:self.view];

Action Sheet warning?

I have added an action sheet in my app. My application is tab bar based app.
I have added this in this way
actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:#"Take photo",#"Use existing photo",nil];
actionSheet.actionSheetStyle = UIBarStyleBlackTranslucent;
[actionSheet showFromTabBar:self.view];
But it shows warning:
How can I remove it. As the same time I am in the tab in which I want to display the action sheet.
[actionSheet showFromTabBar:self.tabBarController.tabBar];
Try this ,it might help you.
If you are in the tab, shouldn't it be [actionSheet showFromTabBar:self.tabBarController.tabBar];?
If you are use tabbar controller then use like this
[actionSheet showFromTabBar:(UITabBar *)[appDelegate.tabBarController view]];

UIActionView Opens Higher than it Should

I have an Action Sheet that is called from my root view controller using the code below. That view has a Toolbar on the bottom of the view measuring 44 pixels high. The problem is when the Action Sheet opens it's not at the bottom of the view, the bottom of the Action View is about 20 or so pixels above the bottom of the view so some of the Toolbar is visible below the Action Sheet. Using the same code on other views I have no such problem. How do I remedy this?
Any help is appreciated!
lq
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:nil
delegate:self
cancelButtonTitle:#"Do Something"
destructiveButtonTitle:#"Do Something Destructive"
otherButtonTitles:nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
[actionSheet release];
If you have a toolbar, use the -showFromToolbar: method instead of -showInView:.

How to display custom view in UIActionSheet?

I have a UIView with a date picker that I'd like to display in an action sheet. I'm using the following code:
-(IBAction) button_click:(id)sender{
//UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:#"the title" delegate:nil cancelButtonTitle:#"Cancel" destructiveButtonTitle:#"Destructive" otherButtonTitles:#"other", nil];
UIActionSheet *sheet = [[UIActionSheet alloc] init];
ActionSheetController *actionSheet = [[ActionSheetController alloc] initWithNibName:#"ActionSheetView" bundle:nil];
[sheet addSubview:actionSheet.view];
[sheet showInView:self.view];
}
What I get is a little bit of the top part of the new view coming up from the bottom and that's it. If I comment the two middle lines of code and uncomment the top part to display a regular action sheet, it works fine. Any ideas what I might be doing wrong?
use UIActionSheetDelegate and after that you can with this delegate add for example a image to button of alertsheet
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet{
UIImageView *sample = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:#"Someimage.png"]];
[actionSheet addSubView:sample];
}
I do not believe you can specify Custom Views in a UIActionSheet. My understanding is that you can only display a title and 1 or more buttons. Below is the description of UIActionSheet in the Apple documentation:
Use the UIActionSheet class to present the user with a set of alternatives for how to proceed with a given task. You can also use action sheets to prompt the user to confirm a potentially dangerous action. The action sheet contains an optional title and one or more buttons, each of which corresponds to an action to take.
UIActionSheet Class Reference
I've discovered the behavoir occurs because I haven't used the UIActionSheet constructor properly. The buttons and title should be included:
UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:#"Date Picker" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
You might want to check out an UIActionSheet alternative I made which lets you display custom content views without any dirty hacks: https://github.com/JonasGessner/JGActionSheet It has some other advantages over UIActionSheet as well!

Strange Problem with UIDatePicker in ActionSheet - Below that Selection indicator I can't select anything, It's become like disabled

I am implementing datepicker with Action Sheet with the following code :
-(void)popupActionSheetWithDatePicker
{
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:#"Done",nil];
UIDatePicker *picker = [[UIDatePicker alloc] init];
self.datePicker = picker;
[self.datePicker setDatePickerMode:UIDatePickerModeDate];
[sheet addSubview:self.datePicker];
[sheet showInView:self.view];
[sheet setBounds:CGRectMake(0,0, 320,500)];
CGRect pickerRect = self.datePicker.bounds;
pickerRect.origin.y = -80;
self.datePicker.bounds = pickerRect;
[sheet bringSubviewToFront:self.datePicker];
[picker release];
[sheet release]; }
Now, The Picker pops up & working perfactly Except below the Selection Indicator.
I mean On & Above the Selection indicator I am able to choose date, month & year, but Below that Selection indicator I can't select anything, It's become like disabled.
Can't find the reason or solution.
If Possible Please send any working Datepicker with UIActionsheet code.
Thanks in advance.
I have had a very similar issue with parts of a view not working when used with a UIActionSheet. My problem was that the bounds of the UIActionSheet were larger than the view I had added it to.
My solutions was to change where i inserted the sheet
[sheet showInView:self.view];
You may need to add it higher up for example
[sheet showInView:self.view.superview];
Hope this at least sets you on the right track
I had this problem also , i supose you have an UIToolbar behind the picker. Just do
[self.navigationController setToolbarHidden:YES];
while in picker , then
[self.navigationController setToolbarHidden:NO];
hope this help