Orientation Changed Notification

来源:互联网 发布:华夏网络工具包 编辑:程序博客网 时间:2024/05/20 04:50

Orientation Changed Notification

Add to #AppDelegate.m didFinishLaunchingWithOptions

//----- SETUP DEVICE ORIENTATION CHANGE NOTIFICATION -----UIDevice *device = [UIDevice currentDevice];//Get the device object[device beginGeneratingDeviceOrientationNotifications];//Tell it to start monitoring the accelerometer for orientationNSNotificationCenter *nc = [NSNotificationCenter defaultCenter];//Get the notification centre for the app[nc addObserver:self//Add yourself as an observer   selector:@selector(orientationChanged:)   name:UIDeviceOrientationDidChangeNotification object:device];
Function To Receive Notification Message
//********** ORIENTATION CHANGED **********- (void)orientationChanged:(NSNotification *)note{NSLog(@"Orientation  has changed: %d", [[note object] orientation]);}
来源:http://www.ios-developer.net/iphone-ipad-programmer/development/notifications/orientation-change-notification
原创粉丝点击