近来学习iOS开发,在研究通知中心的机制(notification center)时,编写了如下代码进行尝试,首先自定义一个类:
@interface Test1NotificationMy1 : NSObject
+(void) orientationChange:(NSNotification *)note;
-(void) orientationChangeInstance:(NSNotification *)note;
@end
@implementation Test1NotificationMy1
+(void) orientationChange:(NSNotification *)note
{
NSLog(@"类方法:方向变化了:%d", [[note object] orientation]);
}
-(void) orientationChangeInstance:(NSNotification *)note
{
NSLog(@"实例方法:方向变化了:%d", [[note object] orientation]);
}
然后在AppDelegate类里注册UIDeviceOrientationDidChangeNotification事件:
@implementation Test1NotificationAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOp