UIActionSheet被其superview剪辑,我没有工具栏或tabbar

时间:2013-09-25 03:19:31

标签: ios ios7 uiactionsheet

我的应用程序使用UINavigationController,但我没有显示工具栏,因为我的所有导航都是由游戏内控件控制的。

我没有Tab栏,因为我没有使用TabBarController。

我的游戏应用仅限景观。

这是我之前创建和呈现UIActionSheet的方式:

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

然而,UIActionSheet主要是在屏幕外,我收到此错误:

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:].

但是,我没有工具栏,也没有标签栏。

我已经尝试了其他几个Stack Overflow答案,但这些答案都不适用于我:

Issue with UIActionSheet

我尝试使用self.parentViewController.view中的self.navigationController.view,来自我创建的CGRect,它位于视图的底部,来自self.view.bounds,因为我很绝望..没有它对我有用。

它适用于iOS 6,但在iOS 7中不起作用。以下是在iOS 6上工作并在iOS 7上失败的几个屏幕截图。

enter image description here

enter image description here

任何帮助?

更新1 ---

以下是所请求的视图层次结构:

<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>>

3 个答案:

答案 0 :(得分:6)

我在同一个应用程序中看起来似乎是一个完全不相关的问题,其中屏幕左侧的一些按钮是无法点击的。

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

在调查我发现我的UIWindow是320x480时。问题出在我的MainWindow.xib上。 Xcode为我创建了这个xib,但它可能是几年前的Xcode 3。我决定检查设置,我注意到“启动时全屏”的选项。我在文档中查找了该选项,并且有一个注释表明应该始终打开,以便正确调整Window的大小以匹配设备大小。当只有一个尺寸的iPhone时,这从来就不是问题,但是随着4“iPhone的推出它成了一个问题。

所以,我检查了那个盒子,重新启动了中提琴,这个问题和其他问题都得到了解决,因为封闭的UIWindow的大小正确。

答案 1 :(得分:3)

我最近通过在主窗口中显示,解决了iOS 7上发生的类似问题(尽管它没有涉及操作表);在你的情况下,它将是这样的:

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

希望它也适用于您的情况。

答案 2 :(得分: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);

链接:Issue with UIActionSheet 表格:user352537