I would like to place a compass, or an image on top of the camera view in my iOS app?
I am creating an app, that would open the camera in the native side with is the iOS, then in the HTML side without using phone gap, or cordova. I am using Native bridging, i would like to place a moving compass on top of the camera view on my iOS app, what methods should i use? any helpful code?
cameraOverlayView property of
UIImagePickerController to set an overlay on top of camera. Check apple documentation for more details. You can add any
UIView as the overlayview.
In order to use the magnetometer, you'll have to use CoreLocation and the following delegate method:
- (void) locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
to rotate a
UIView to point North:
float heading = newHeading.magneticHeading; //in degrees float headingDegrees = (heading*M_PI/180); //assuming needle points to top of iphone. convert to radians self.imageView.transform = CGAffineTransformMakeRotation(headingDegrees);
You might also find these questions useful: