ファイルorientationChanged:
で宣言せずにアクセスできるのはなぜですか? .h
Apple のドキュメントでメソッドを見つけることができなかったので、継承されたメソッドではないと思います。
#import <UIKit/UIKit.h>
@interface RotationAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
#import "RotationAppDelegate.h"
@implementation RotationAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIDevice *device = [UIDevice currentDevice];
[device beginGeneratingDeviceOrientationNotifications];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:device];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
-(void)orientationChanged:(NSNotification *)note {
NSLog(@"oriendtationChanged: %i", [[note object] orientation]);
}