gpt4 book ai didi

ios - UIWindow 中存在 UIAlertContoller ios8

转载 作者:行者123 更新时间:2023-11-29 12:35:30 25 4
gpt4 key购买 nike

我有一个应用程序,当我点击屏幕上的表格 View 中的项目时,会打开全屏照片演示。

它是全屏的,所以我将它直接添加到主窗口 [[[UIApplication sharedApplication] windows] objectAtIndex:0] over my viewcontroller。

我为每个图像都有一个菜单,当我点击显示图像的 UIBarButton 时,它会打开。我用代码 [self.imageActionSheet showFromBarButtonItem:sendButtonItem animated:YES];

打开我的 UIActionSheet(self.imageActionSheet)

它在 ios7 上运行良好,但在 iPad 上的 ios8 上它无法打开。

我发现在 ios8 中 ActionSheet 已被弃用,我应该使用 UIAlertController。

我为它做了一个测试alertcontroller

            UIAlertController * actionSheet = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];

[actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

}]];

UIPopoverPresentationController *popover = actionSheet.popoverPresentationController;
if (popover)
{
UIView *buttonView = [sendButtonItem valueForKey:@"view"];
popover.sourceView = buttonView;
popover.sourceRect = buttonView.bounds;
popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
}
UIWindow * wind = [[[UIApplication sharedApplication] windows] objectAtIndex:0];

[wind.rootViewController presentViewController:actionSheet animated:YES completion:nil];

它显示了,但它显示在我的全屏 View 下,它包含在 [[[UIApplication sharedApplication] windows] objectAtIndex:0] 中,就像 subview 一样。它包含在 keyWindow 中,因为我需要重叠所有界面。

我找到了一种方法,只通过 ViewContoller 显示 UIAlertController,但我的所有 viewController 都在我的全屏 View 下。

如何在 UIWindow 上显示 UIAlertController?或者可能来自 UIBarButtonItem?

最佳答案

您可以创建自己的 UIWindow 并在其中放入任何您想要的内容,它将位于包括状态栏在内的所有内容之上。我没有一个方便的例子,但你可以找到它们。查找构建您自己的 UIAlertViewController 的示例。我在之前的工作中使用它来构建一个警报,其中可以包含任意数量的项目。

关于ios - UIWindow 中存在 UIAlertContoller ios8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26463991/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com