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