Fixing The Dreaded ‘Invoked Recursively’ UIAlertController Issue

While working on a recent project I came across an issue that seems to have no documented fix for in any forums, apple publications, stack overflow articles or any other go to spots on the web for these issues. After searching the web for close to a week to find a fix for this (yes, it’s seriously that hard to find a fix for) I came across the suggestion to override the class of the UIAlertController itself.

Understanding the issue
It seems that apple have not really put alot of thought into the iOS 9 SDK. I say this because the issue only occurs in SDK’s greater than iOS 9 and is actually quite a simple fix that would’ve taken dev’s around 2 minutes to patch in. What’s happening is that the UIAlertController is relying on a deprecated method to get the supportedInterfaceOrientations of your app but can’t fetch them because the method no longer exists.

Fixing the issue
As mentioned above, the fix is quite simple. You will need to create the following two files in your project:


//  UIAlertController+supportedInterfaceOrientations.h

#import <UIKit/UIKit.h>

@interface UIAlertController (supportedInterfaceOrientations)



//  UIAlertController+supportedInterfaceOrientations.m

#import "UIAlertController+supportedInterfaceOrientations.h"

@implementation UIAlertController (supportedInterfaceOrientations)

- (NSUInteger)supportedInterfaceOrientations; {
    return UIInterfaceOrientationMaskPortrait;
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;


Now just import this file into any class that uses a UIAlertController by placing #import “UIAlertController+supportedInterfaceOrientations.h” into your imports declarations. You’ll now have a working UIAlertController and hopefully can move on with your project.

Join the discussion One Comment

  • Gadget Ninja says:

    Everything is very ope with a very clear explanation of the issues.
    It was truly informative. Your site is useful.Thanks for sharing!

Leave a Reply to Gadget Ninja Cancel Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.