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(@"układ pionowy");
            } else {
               NSLog(@"układ poziomy");
            }
   }];
