UIActionSheet is clipped by its superview, I don't have a toolbar or tabbar
Asked Answered
H

3

12

My app uses a UINavigationController, but I do not show the toolbar because all of my navigation is controlled by in-game controls.

I do not have a Tab bar, because I'm not using a TabBarController.

My game app is Landscape only.

This is how I previously created and presented the UIActionSheet:

UIActionSheet *quitGameSheet = [[UIActionSheet alloc] 
     initWithTitle:@"Quit your game?" 
     delegate:self
     cancelButtonTitle:@"Cancel"
     destructiveButtonTitle:@"Yes, quit game"
     otherButtonTitles:nil];
[quitGameSheet showInView:self.view];

However, the UIActionSheet is mostly off screen and I get this error:

Presenting action sheet clipped by its superview. Some controls might not respond to touches. On iPhone try -[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:] instead of -[UIActionSheet showInView:].

However, I do not have a toolbar and I do not have a tabbar.

I've tried several other Stack Overflow answers, none of which work for me:

Issue with UIActionSheet

I tried presenting it from self.navigationController.view, from self.parentViewController.view, from a CGRect that I created which was at the bottom of the view, from self.view.bounds because I was desperate.. none of it works for me.

It works in iOS 6, but does not work in iOS 7. Here are a couple of screenshots of it working on iOS 6 and failing on iOS 7.

enter image description here

enter image description here

Update

Here is a view hierarchy as requested:

<UIView: 0xc480380; frame = (0 0; 568 320); autoresize = RM+BM; layer = <CALayer: 0xc4803e0>>
   | <UIImageView: 0xc480410; frame = (0 0; 568 320); opaque = NO; autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0xc4804a0>>
   | <UIButton: 0xc47b370; frame = (203 107; 159 37); opaque = NO; autoresize = LM+RM+BM; layer = <CALayer: 0xc47a730>>
   |    | <UIImageView: 0xc475150; frame = (0 0; 159 37); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xc4751e0>>
   | <UIButton: 0xc478a00; frame = (203 152; 159 37); opaque = NO; autoresize = LM+RM+BM; layer = <CALayer: 0xc477dd0>>
   |    | <UIImageView: 0xc475030; frame = (0 0; 159 37); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xc4750c0>>
   | <UISwitch: 0xc47dcc0; frame = (313 65; 51 31); opaque = NO; autoresize = LM+RM+BM; layer = <CALayer: 0xc47d180>>
   |    | <_UISwitchInternalViewNeueStyle1: 0xc47e040; frame = (0 0; 51 31); gestureRecognizers = <NSArray: 0xc47ffa0>; layer = <CALayer: 0xc47e140>>
   |    |    | <UIView: 0xc47e4e0; frame = (35.5 0; 15.5 31); clipsToBounds = YES; layer = <CALayer: 0xc47e540>>
   |    |    |    | <UIView: 0xc47e330; frame = (-35.5 0; 51 31); layer = <CALayer: 0xc47e390>>
   |    |    | <UIView: 0xc47e450; frame = (0 0; 35.5 31); clipsToBounds = YES; layer = <CALayer: 0xc47e4b0>>
   |    |    |    | <UIView: 0xc47e3c0; frame = (0 0; 51 31); layer = <CALayer: 0xc47e420>>
   |    |    | <UIView: 0xc47f750; frame = (0 0; 51 31); layer = <CALayer: 0xc47f7b0>>
   |    |    |    | <UIImageView: 0xc47f480; frame = (39 16; 0 0); alpha = 0; userInteractionEnabled = NO; layer = <CALayer: 0xc47f660>>
   |    |    |    | <UIImageView: 0xc47f690; frame = (12 16; 0 0); userInteractionEnabled = NO; layer = <CALayer: 0xc47f720>>
   |    |    | <UIImageView: 0xc47e680; frame = (7 -6; 57 43.5); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xc47f2f0>>
   | <UILabel: 0xc480610; frame = (173 63; 96 29); text = 'Sounds:'; clipsToBounds = YES; opaque = NO; autoresize = LM+RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0xc480540>>
   | <UIButton: 0xc473a20; frame = (203 197; 159 37); opaque = NO; autoresize = LM+RM+BM; layer = <CALayer: 0xc473590>>
   |    | <UIImageView: 0xc474f30; frame = (0 0; 159 37); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xc474fc0>>
Him answered 25/9, 2013 at 3:19 Comment(9)
Hi, set opeque to NO and add on navigation.view instead of self.view...Skolnik
Set what to opaque=NO?Him
What item are you suggesting I set to opaque?Him
I want to set Action sheet like:actionsheet.opaque = NO;Skolnik
Could you attached a description of your view hierarchy? Use (gdb) po [[self view] recursiveDescription]Seventeen
How do I get access to gdb when I'm not a at a breakpoint? If you do want it while I'm at a break point, how should I get that while the Action Sheet is visible?Him
I figured out a way to get it. I've updated the question above.Him
Have you tried [quitGameSheet showInView:self.navigationController.view]?Camilia
Yeah, I tried that as well. I just posted, about a minute ago, that I discovered the actual problem and fixed it. Check my answer below.Him
H
6

I had what appeared to be a completely unrelated problem in the same app, wherein some of the buttons on the left side of the screen weren't tappable.

Can't tap buttons on the left side of 4" iPhone

While investigating that I discovered that my UIWindow was 320x480. The problem was in my MainWindow.xib. Xcode created this xib for me, but it was probably Xcode 3 and it was several years ago. I decided to review the settings and I noticed the option for "Full Screen at Launch." I looked up that option in the docs and there was a note stating that this should always be on so that the Window is properly resized to match the device size. This was never an issue when there was only one size iPhone, but it became a problem with the introduction of the 4" iPhone.

So, I checked that box, and relaunched and viola, both this and the other problem were solved because the enclosing UIWindow was correctly sized.

Him answered 30/9, 2013 at 19:32 Comment(0)
B
3

I have recently solved a similar issue happening on iOS 7 (although it did not involve an action sheet) by presenting in the main window; in your case it would be something like:

[quitGameSheet showInView:[UIApplication sharedApplication].keyWindow];

hope it will work in your case as well.

Beggarweed answered 4/10, 2013 at 15:36 Comment(1)
I tried this as well, but it didn't work because the .keyWindow was not sized correctly. The solution was to make sure the UIWindow was properly being resized as I describe above.Him
P
0
[sheet showInView:[UIApplication sharedApplication].keyWindow];
sheet.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height-    
sheet.frame.size.height, [UIScreen mainScreen].bounds.size.width, 
sheet.frame.size.height);

Link: Issue with UIActionSheet Form: user352537

Pantin answered 11/10, 2013 at 6:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.