LoginSignup
2
1

More than 5 years have passed since last update.

iOS 9 で UIAlertController を表示時に「UIAlertController:supportedInterfaceOrientations was invoked recursively!」

Last updated at Posted at 2015-10-09

事象

題名の通り、UIAlertController を -presentViewController:animated:completion: しようとすると UIAlertController:supportedInterfaceOrientations was invoked recursively! のログを吐きつつクラッシュする。

対応

以下のサブクラスを作成し、使用するように変更。

OSAlertController.h
#import <UIKit/UIKit.h>

@interface OSAlertController : UIAlertController

- (instancetype)initWithOrientationMask:(UIInterfaceOrientationMask)orientationMask;

@end
OSAlertController.m
#import "OSAlertController.h"

@interface OSAlertController ()

@property (nonatomic) UIInterfaceOrientationMask orientationMask;

@end


@implementation OSAlertController

- (instancetype)init {
    self = [super init];
    if (self) {
        [self setOrientationMask:UIInterfaceOrientationMaskAllButUpsideDown];
    }
    return self;
}

- (instancetype)initWithOrientationMask:(UIInterfaceOrientationMask)orientationMask {
    self = [super init];
    if (self) {
        [self setOrientationMask:orientationMask];
    }
    return self;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return _orientationMask;
}

@end
2
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1