UIAlertController ios8出现在UIWindow中

UIAlertController ios8出现在UIWindow中,ios,objective-c,ios8,uiactionsheet,uialertcontroller,Ios,Objective C,Ios8,Uiactionsheet,Uialertcontroller,我有一个应用程序,当我在屏幕上点击tableview中的项目时,会打开全屏照片演示 它是全屏的,所以我通过我的viewcontroller将它直接添加到主窗口[[[UIApplication sharedApplication]windows]objectAtIndex:0] 我为每个图像都有一个菜单,当我点击显示图像的UIBarButton时,它就会打开。我打开我的UIActionSheet(self.imageActionSheet),其中代码[self.imageActionSheet s

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

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

我为每个图像都有一个菜单,当我点击显示图像的UIBarButton时,它就会打开。我打开我的
UIActionSheet(self.imageActionSheet)
,其中代码
[self.imageActionSheet showFromBarButtonItem:sendButtonItem动画:是]

它在ios7上运行得非常好,但在iPad上的ios8上它无法打开

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

我做了一个测试

            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];
它显示,但它显示在我的全屏视图下,该视图包含在
[[UIApplication sharedApplication]windows]objectAtIndex:0]
子视图中。它包含在keyWindow中,因为我需要重叠所有接口

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


如何在UIWindow中显示UIAlertController?或者从UIBarButtonItem?

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

不,它仍然在我的全屏视图下,我认为这是因为全屏视图位于keyWindow层次结构的一个级别上,但后来在主VC上添加了全屏。
Please try like this..

AppDelegate* appDelegate = [[UIApplication sharedApplication] delegate];
        UIViewController* topVC = appDelegate.navC.topViewController;
        if (topVC.presentedViewController)
            topVC = topVC.presentedViewController;
        [topVC presentViewController:alertViewController animated:NO completion:nil];