Here are the source files used during bilambee’s lightning talk at iPadMadCamp.
iPadAccelAppDelegate.m
-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
-
-
// Override point for customization after application launch.
-
-
// Add the view controller's view to the window and display.
-
[window addSubview:viewController.view];
-
[window makeKeyAndVisible];
-
-
-
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
-
-
[[NSNotificationCenter defaultCenter] addObserver:viewController
-
selector:@selector(orientationChange)
-
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
-
-
return YES;
-
}
iPadAccelViewController.h
-
@interface iPadAccelViewController : UIViewController {
-
-
}
-
-
-(void)orientationChange;
-
-
@end
iPadAccelViewController.m
-
-(void)orientationChange {
-
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
-
-
switch (orientation) {
-
case UIDeviceOrientationFaceUp:
-
NSLog(@"* FaceUp");
-
break;
-
case UIDeviceOrientationFaceDown:
-
NSLog(@"* FaceDown");
-
break;
-
case UIDeviceOrientationLandscapeLeft:
-
NSLog(@"* Left");
-
break;
-
case UIDeviceOrientationLandscapeRight:
-
NSLog(@"* Right");
-
break;
-
case UIDeviceOrientationPortrait:
-
NSLog(@"* Port");
-
break;
-
case UIDeviceOrientationPortraitUpsideDown:
-
NSLog(@"* PortDown");
-
break;
-
case UIDeviceOrientationUnknown:
-
NSLog(@"* Unknown");
-
break;
-
default:
-
break;
-
}
-
-
}
Any questions?
