Reputation: 589
I have an app where when i tap on item in tableview on screen opens fullscreen photo presentation.
It is fullscreen so i add it directly to main window [[[UIApplication sharedApplication] windows] objectAtIndex:0]
over my viewcontroller.
I have a menu for each image, it opens when i tap on UIBarButton that presents with image. i open my UIActionSheet(self.imageActionSheet)
with code [self.imageActionSheet showFromBarButtonItem:sendButtonItem animated:YES];
It works awesome on ios7, but on ios8 on iPad it doesn't opens.
I found that in ios8 ActionSheet is deprecated, and i should use UIAlertController.
I made a test alertcontroller for it
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];
It shows, but it shows under my fullscreen view that contained in [[[UIApplication sharedApplication] windows] objectAtIndex:0]
like subview. It contained at keyWindow because i need overlap all interface.
I found a way only present UIAlertController via ViewContoller, but all my viewControllers under my fullscreen view.
How i can show UIAlertController at UIWindow? or maybe from UIBarButtonItem?
Upvotes: 1
Views: 1552
Reputation: 2584
You can create your own UIWindow and put whatever you want in it, and it will be above everything including the status bar. I don't have a handy like to an example but you can find them. Look for examples of building your own UIAlertViewController. I used this at a previous job to build an alert that could have any number of items in it.
Upvotes: 1
Reputation: 43
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];
Upvotes: 0