Issue with UIActionSheet

帅比萌擦擦* 提交于 2019-11-28 23:39:23

问题


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?


回答1:


Try this, it worked for me perfectly:

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



回答2:


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




回答3:


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.




回答4:


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




回答5:


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.




回答6:


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




回答7:


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

[actionSheet showInView:self.view.superview];



回答8:


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




回答9:


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.




回答10:


Heres the Swift version:

actionSheet.showInView(UIApplication.sharedApplication().keyWindow)


来源:https://stackoverflow.com/questions/4456982/issue-with-uiactionsheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!