操作表未在iPad上显示“取消”按钮 [英] Action sheet doesn't show Cancel button on iPad

查看:95
本文介绍了操作表未在iPad上显示“取消”按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iphone上,此代码显示取消按钮:

On the iphone, this code shows the cancel button:

- (IBAction)buttonPressed
{
    UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                  initWithTitle:@"Are you sure?"
                                  delegate:self 
                                  cancelButtonTitle:@"No way!"
                                  destructiveButtonTitle:@"Yes, I'm sure!"
                                  otherButtonTitles:nil];
    [actionSheet showInView:self.view];
    [actionSheet release];  
}

但在iPad上,只显示破坏性按钮。

有什么问题?

But on the iPad, only the destructive button shows.
What's the problem?

推荐答案

我能够通过设置actionSheetStyle来解决这个问题:

I was able to solve this by setting the actionSheetStyle:

actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;

UIActionSheetStyleBlackTranslucent也有效。我正在从模态视图控制器显示动作表,我认为这在技术上并不像指南所说的popovercontroller但是当它出现在模态视图顶部时,没有看到动作表上的取消按钮看起来不正确。所有用户看到的都是一个可怕的红色按钮,没有可见的选择。

UIActionSheetStyleBlackTranslucent also works. I am displaying the action sheet from a modal view controller which I guess is not technically a "popovercontroller" like the guidelines say but not seeing a Cancel button on the action sheet doesn't look right when it appears on top of the modal view. All the user sees is one scary red button with no visible alternative.

也许我可以将模态视图控制器更改为popovercontroller但是它不会是模态的需要。

Maybe I could change the modal view controller to a popovercontroller but then it wouldn't be modal which it needs to be.

- 更新 -

这很有趣虽然它已经持续但在iOS 4.2中不再有效。

我改用了UIAlertView而不是UIActionSheet。

我不再得到一个很酷的红色按钮但它得到了工作完成。

Well it was fun while it lasted but this no longer works in iOS 4.2.
I switched to using a UIAlertView instead of a UIActionSheet.
I no longer get a cool red button but it gets the job done.

这篇关于操作表未在iPad上显示“取消”按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆