简体   繁体   English

在UIActionSheet中,取消按钮不显示给iphone吗?

[英]In UIActionSheet the cancel button not showing for iphone?

In my application when I click on change image it's asks UIActionsheet with three actions take photo ,choose from library and cancel.Take photo ,choose from library are showing but cancel didn't showing where is the problem. 在我的应用程序中,当我单击更改图像时,它要求UIActionsheet进行三项操作:拍照,从库中选择并取消。拍照,从库中进行选择正在显示,但取消没有显示出问题所在。 this is my code 这是我的代码

    - (void)viewDidLoad
{
         [super viewDidLoad];
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..."
        delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose from library", nil];
        actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
        actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
        [actionSheet showInView:self.view];
}

这是因为...我认为您使用的是默认的视图大小-Retina 4全屏作为视图大小...只需尝试从属性检查器将视图大小更改为Retina 3.5全屏... !!!

try this one... 试试这个...

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..." 
                                                         delegate:self
                                                cancelButtonTitle:@"Cancel"
                                           destructiveButtonTitle:@"Cancel"
                                                otherButtonTitles:@"Take Photo", @"Choose from library", nil];

    actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
    [actionSheet showInView:self.view];

You may want to take a look at the alternative methods for presenting an action sheet in the class reference . 您可能需要看一看在类参考中提供操作表的替代方法。 However, you may want to try using one of the following (if you have a toolbar) 但是,您可能要尝试使用以下方法之一(如果有工具栏)

– showFromBarButtonItem:animated:
– showFromToolbar:

Additionally, using the following 此外,使用以下内容

actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

will only ever result in the action sheets style being default. 只会导致动作表样式为默认样式。

Please refer this link . 请参考此链接

And you can refer below code also, it may help you: 您也可以参考以下代码,它可能对您有帮助:

(void)viewDidLoad
    {

    UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..." delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose from library", nil];
    [actionSheet showInView:self.view];

    }

Since your problem is not with your code. 由于您的问题不在于您的代码。 Maybe you are using the wrong method to display your UIActionSheet. 也许您使用了错误的方法来显示UIActionSheet。

A UIActionSheet can be displayed with following methods: 可以使用以下方法显示UIActionSheet:

– showFromTabBar:
– showFromToolbar:
– showInView:
– showFromBarButtonItem:animated:
– showFromRect:inView:animated:

take a look at Apple's UIActionSheet reference . 看一下Apple的UIActionSheet参考

Since you use a TabBar, the Cancel button may also be below. 由于使用的是TabBar,“取消”按钮也可能位于下方。 I would test that too. 我也会测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM