ios - 当用户触摸外部弹出窗口时,在 ipad 上禁用 ActionSheet dismiss

标签 ios ipad uiactionsheet popover

我的应用程序中显示了一个操作表,它在 iphone 上运行良好。但是,在 ipad 上,它会自动在弹出窗口中创建操作表,我无法让它在用户触摸操作表外部时禁用消失。

我已经更改了操作表在 ipad 上的显示方式,现在使用以下方式显示:

        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Choose a preloaded picture", @"Use a photo", nil];
    actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    actionSheet.tag = 1;
    [actionSheet showFromRect:CGRectMake(100, 0, 300, 300) inView:self.view animated:YES];
    [actionSheet release];

我也试过用。

- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
{
     return NO;
}

关于如何在用户触摸操作表外部时阻止 uiactionsheet 弹出窗口消失的想法?

最佳答案

您的 popoverControllerShouldDismissPopover: 方法不会被调用,因为它是 UIPopoverControllerDelegate 方法,而您正在处理 UIActionSheet。由于 UIKit 会自动为您创建 popover Controller ,您将没有机会设置它的委托(delegate)。您可以使用 [popoverActionsheet superview] 访问弹出 View 本身,但这不会为您提供 UIPopoverController。

从用户体验的角度来看,Apple 会要求您不要实现此类行为 — 如果您需要以模态方式呈现选项(在用户做出选择之前它们不会消失),那么用户会更喜欢熟悉 UIAlertView,或 a modally-presented view controller of your own .

关于ios - 当用户触摸外部弹出窗口时,在 ipad 上禁用 ActionSheet dismiss,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8094336/

相关文章:

ipad - 改变 iPad 方向,旋转状态栏,工具栏,但不是主视图

ios - Apple 是如何做到这样的?

Android:相当于 iOS UIActionSheet

iphone - 在 iOS 设备上访问以编程方式创建的日历

ios - 如何在 Swift 中使用我自己的函数创建一个文件

ios - 有没有办法在 iOS 4.2 之前的设备上使用 Core MIDI?

objective-c - 如何在 Objective C 中添加 CSS

IOS CollectionView 页脚添加 Google AdMob

iphone - 在 UITableView 的完成按钮上隐藏 UIPickerview

css - 响应式网站在 iPad 上放大显示