Created
July 15, 2011 21:55
-
-
Save darkseed/1085628 to your computer and use it in GitHub Desktop.
Block based notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; | |
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; | |
[nc addObserverForName:UIDeviceOrientationDidChangeNotification object:nil | |
queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif){ | |
UIDeviceOrientation orientation; | |
orientation = [[UIDevice currentDevice] orientation]; | |
if (UIDeviceOrientationIsPortrait(orientation)) { | |
NSLog(@"portrait"); | |
} else { | |
NSLog(@"landscape"); | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment