iOS8.3 UIAlertController
iOS8でUIAlertControllerになってからアラートが回転して困ってたら
それが原因で
return [self.visibleViewController supportedInterfaceOrientations];
の際にiOS8.3だとクラッシュするようになってしまった。
UIAlertController+Rotation.h
#import <UIKit/UIKit.h>
@interface UIAlertController(Rotation)
@end
UIAlertController+Rotation.m
#import "UIAlertController+Rotation.h"
@implementation UIAlertController(Rotation)
#pragma mark self rotate
– (BOOL)shouldAutorotate {
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if ( orientation == UIDeviceOrientationPortrait
| orientation == UIDeviceOrientationPortraitUpsideDown) {
return YES;
}
return NO;
}
– (NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
– (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
UIDevice* device = [UIDevice currentDevice];
if (device.orientation == UIInterfaceOrientationPortraitUpsideDown) {
return UIInterfaceOrientationPortraitUpsideDown;
}
return UIInterfaceOrientationPortrait;
}
@end
って感じにしたらイケた。
UIAlertController(Rotation)
みたいなクラス拡張時の(Rotation)とかってなんか仕様があってその拡張かと思ってたけど
+~の~と一致させればいいだけなのでコレ便利だわ。
他の言語じゃ使えないから多様はしたくないけど