I'm trying to display an ActionSheet when a screen is touched within scrollview. The action sheet pops fine within the first page. But on subsequent pages the screen becomes dark and doesn't displaying anything, as if actual button is displaying on the off screen. I have tested different frame positioning of UIActionSheet but it does not seem to work.
self.view.frame.origin.x seems to have correct ScrollView position.
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:nil
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:#"Jump to First Page", #"Browse Pages",nil];
CGRect frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, 480.0f, 320.0f);
[actionSheet setFrame:frame];
[actionSheet showInView:self.view];
Assuming your UIScrollView is contained in the view of a UIViewController.
You should then display that UIActionSheet inside the root view of the view controller.
You are displaying it inside the scrollview, which will not work, because you are right, it is displayed off screen. you shouldn't display it inside the scrollview, rather, put the Scrollview in another view and display the ActionSheet inside that view.
Related
I have one view controller added as subview in some other view controller and in that sub view controller I am presenting a UIAlertview. After dismissing that alert view the view become unresponsive to touch. It becomes active again when I minimize the application and launch it again.
Any thoughts..
Here is code that I am using,
First I added child view controller as subview in my main view controller inside a uiscrollview.
SharedViewController *sharedVC = [[SharedViewController alloc] initWithNibName:#"SharedViewController" bundle:nil];
[sharedVC.view setFrame:CGRectMake(2048, 0, 1024, 545)];
sharedVC.delagate = self;
[mainScrollView addSubview:sharedVC.view];
And in SharedViewController I have a button tapping on which I do this,
[[[UIAlertView alloc] initWithTitle:#"MyApp" message:#"No File selected. Please select some of them and try again." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles: nil] show];
After presenting the alertview and atpping OK button the view becomes unresponsive unless I minimize the app and open it again.
I also faced this problem recently. Hopefully your problem is solved. My answer may help others. Do not add any view or present any view or remove any view or even push after the alert show code. The following was my code, and I was facing the same problem:
UIAlertView *errorLert = [[UIAlertView alloc] initWithTitle:#"Erro" message:#"Operation could not be performed at this time, please try again later" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[errorLert show];
[customView removeFromSuperView];
then I just removed my last line and shifted before the alert and it worked for me.
after work of sub view controller is done you have to add following line..
I am not sure but may you get help..
[sharedVC removeFromSuperview];
if (sharedVC.view.superview==Nil) {
CGRect frame = mainScrollView.frame;
frame.origin.x = frame.size.width;
frame.origin.y = 0;
sharedVC.view.frame = frame;
[mainScrollView addSubview:sharedVC.view];
}
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];
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:.
I learned how to create a view controller and make the view slide in from bottom. But the one in iphone album looks different. It darkens the rest of the visible portion of the screen when the view slides in. How do I create a similar one? I want to add buttons like "save, cancel, email" etc into the sliding view.
This actually isn't a typical "sliding" (or modal) view, but a UIActionSheet. Basically, the idea is that you initialize the view (usually in your view controller) with
UIActionSheet *sheet =
[[[UIActionSheet alloc] initWithTitle:#"My sheet"
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:#"Email", #"MMS", nil] autorelease];
Then present it using
[sheet showInView:[self view]];
Once it's onscreen, the delegate (self, or your view controller, in this example) will receive the UIActionSheetDelegate message actionSheet:clickedButtonAtIndex: (as well as some others; see the documentation for more), so you'll want to add <UIActionSheetDelegate> to your interface declaration for the delegate and implement that method, like
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
switch(buttonIndex) {
// Do things based on which button was pushed
}
}
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];