Issue with UIActionSheet
Asked Answered
S

10

36

When I run my app and I click button for actionsheet appears this:

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

How can I fix?

Sourdine answered 16/12, 2010 at 2:33 Comment(0)
A
61

Try this, it worked for me perfectly:

[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
Alver answered 23/7, 2012 at 9:34 Comment(3)
perfectly :)) just what I was looking for!!Gregarine
@Alver theres a problem with this if youopen the actionsheet in landscape mode. the actionsheet will enter the screen from the side and it will be rotated by 90 degrees. do you have any solution for that? because otherwise its really helpful. tia.Mosora
very similar but less code and easier to remember, you could do: [actionSheet showInView:self.view.window]Kat
O
28

You could try [MyActionSheet showInView:super.view]; or if you have a UITabBar or UIToolbar then, as it suggests, you can use [MyActionSheet showFromTabBar:self.tabBarController.tabBar]; or [MyActionSheet showFromToolBar:self.toolbar];

Oosphere answered 16/12, 2010 at 2:42 Comment(0)
H
12

It should be resolved to use [actionSheet showInView:self.parentViewController.view]; instead of self.view if you are using UINavigationViewController because this controller has top navigation bar as default.

Homophile answered 19/7, 2011 at 8:20 Comment(1)
or self.navigationController.view ThanksLipski
J
5
    [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);

This should solve the problem.

Jarib answered 30/9, 2013 at 7:9 Comment(1)
Thanks, this one was the only to work it out for me (with slight additions to work both with and without navigation controller). A had similar problem with a custom iOS6 + iOS7 window configuration, when for iOS7 you shift your window down 20 points and leave everything as it is.Siloum
S
1

I resolved my nearly-the-same case by:

YourAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[actionSheet showFromTabBar:delegate.tabBarController.tabBar];

assume you use TabBarController xCode template as a start.

Spirogyra answered 11/10, 2011 at 2:31 Comment(0)
S
0

Remember that your toolbar may be part of your navigation controller. You can access it with self.navigationController.toolbar

Singley answered 9/2, 2013 at 21:54 Comment(0)
A
0

Another similar solution, which worked for me with a UIPageViewController -> UINavigationViewController -> TableViewController structure, is:

[actionSheet showInView:self.view.superview];
Aleppo answered 18/6, 2014 at 18:5 Comment(0)
K
0

Use this:

[actionSheet showInView:self.view.window];

This will force the action sheet to be displayed above navigation bars and respond to all taps. Note however that if you use some left/right sliding menu libraries, this may result in the actionSheet to be presented off screen. Just test...

Kat answered 20/6, 2014 at 6:8 Comment(0)
S
0

I tried all of the above answers to no avail. Ultimately, I found that the only solution was to reduce the number of items on the action sheet, which was overflowing.

Syck answered 13/8, 2014 at 13:28 Comment(0)
S
0

Heres the Swift version:

actionSheet.showInView(UIApplication.sharedApplication().keyWindow)
Simms answered 17/8, 2015 at 9:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.