Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mimicking iOS 6 camera rotation

I have been doing some experiments with a custom camera using AVFoundation and so far everything's been great. The AVCam example got me very far and I am quite happy with the results.

However, one thing I still don't get is how the iOS default Camera app handles rotations. It seems like the background does not rotate at all but all the overlay controls do.

This is probably not a camera-specific question but how could I achieve this behaviour?

TLDR: Have a background camera layer, controls on top, how to rotate controls without rotating the background layer?

like image 591
defer Avatar asked Dec 16 '12 20:12

defer


1 Answers

I've been wondering on the same...

My guess would be that the native Camera viewController doesn't rotate using the UIViewController rotation mechanism

  • no status bar rotation
  • no 'basic' rotation of subviews - toolbar doesn't move, buttons are animated
  • and of course the view containing the camera preview doesn't rotate :)

Rather it must call [UIDevice beginGeneratingDeviceOrientationNotifications] and handle specific UI update (grey buttons fading position switching, and toolbar buttons image rotation)

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(yourUpdateMethodForRotation:) notificationName: UIDeviceOrientationDidChangeNotification];
like image 58
Vinzzz Avatar answered Nov 15 '22 00:11

Vinzzz