i`m building an app wich notify the user when getting to the max speed limit "120 km/h"
but i`m not getting the exact speed value when testing the app while driving
lets say i`m driving at 80 km/h speed , the value i get from the app is a range between 60 - 100 sometimes more changing every second.
this is my whole code i`m using
viewController.h
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import "CoreLocationController.h"
#import <MapKit/MapKit.h>
#interface ViewController : UIViewController <CLLocationManagerDelegate, CoreLocationControllerDelegate> {
MKMapView *mapview;
CLLocationManager *locationManager;
IBOutlet UILabel *speedLabel;
CoreLocationController *CLController;
int distance;
int currentSpeed;
int maxSpeed;
IBOutlet UILabel *distanceLbl;
IBOutlet UILabel *maxSpeedLbl;
IBOutlet UILabel *currentSpeedLbl;
}
- (IBAction)Getlocation:(id)sender;
#property (nonatomic, retain) IBOutlet UILabel *distanceLbl;
#property (nonatomic, retain) IBOutlet UILabel *maxSpeedLbl;
#property (nonatomic, retain) IBOutlet UILabel *currentSpeedLbl;
#property (retain, nonatomic) IBOutlet UILabel *speedLabel;
#property (nonatomic, retain) CoreLocationController *CLController;
#property (retain, nonatomic) IBOutlet MKMapView *mapview;
#property (strong, nonatomic) IBOutlet CLLocationManager *locationManager;
viewController.m
#synthesize distanceLbl,maxSpeedLbl,currentSpeedLbl;
#synthesize locationManager;
#synthesize mapview;
#synthesize speedLabel;
#synthesize CLController;
- (void)locationChange:(CLLocation *)newLocation:(CLLocation *)oldLocation {
NSTimeInterval difference = [[newLocation timestamp] timeIntervalSinceDate:[oldLocation timestamp]];
double temp_distance = [newLocation getDistanceFrom:oldLocation];
distance += temp_distance;
distanceLbl.text = [NSString stringWithFormat:#"%.2d",distance];
currentSpeed = (temp_distance/difference) * (18.0/5.0);
if (currentSpeed > maxSpeed) {
maxSpeed = currentSpeed;
maxSpeedLbl.text = [NSString stringWithFormat:#"%.2d",maxSpeed];
}
currentSpeedLbl.text = [NSString stringWithFormat:#"%.2d",currentSpeed];
}
- (void)locationUpdate:(CLLocation *)location {
speedLabel.text = [NSString stringWithFormat:#"SPEED: %f", [location speed]];
self.mapview.showsUserLocation = YES;
}
- (void)locationError:(NSError *)error {
speedLabel.text = [error description];
}
- (IBAction)Getlocation:(id)sender {
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.delegate = self;
[locationManager startUpdatingLocation];
[mapview setMapType:MKMapTypeStandard];
[mapview setZoomEnabled:YES];
[mapview setScrollEnabled:YES];
self.mapview.showsUserLocation = YES;
MKCoordinateRegion region = { {0.0, 0.0 }, {0.0, 0.0 } };
region.center.latitude = locationManager.location.coordinate.latitude;
region.center.longitude = locationManager.location.coordinate.longitude;
region.span.longitudeDelta = 0.007f;
region.span.latitudeDelta = 0.007f;
[mapview setRegion:region animated:YES];
[mapview setDelegate:sender];
}
- (IBAction)setMap:(id)sender {
switch (((UISegmentedControl *) sender).selectedSegmentIndex) {
case 0:
mapview.mapType = MKMapTypeStandard;
break;
case 1:
mapview.mapType = MKMapTypeSatellite;
break;
case 2:
mapview.mapType = MKMapTypeHybrid;
break;
default:
break;
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
CLController = [[CoreLocationController alloc] init];
CLController.delegate = self;
[CLController.locMgr startUpdatingLocation];
[self Getlocation:self];
maxSpeed = 120;
}
CoreLocationController.h
#protocol CoreLocationControllerDelegate
#required
- (void)locationUpdate:(CLLocation *)location;
- (void)locationError:(NSError *)error;
- (void)locationChange:(CLLocation *)newLocation:(CLLocation *)oldLocation;
#end
#interface CoreLocationController : NSObject <CLLocationManagerDelegate> {
CLLocationManager *locMgr;
id delegate;
//new speed method
int distance;
int currentSpeed;
int maxSpeed;
IBOutlet UILabel *distanceLbl;
IBOutlet UILabel *maxSpeedLbl;
IBOutlet UILabel *currentSpeedLbl;
}
#property (nonatomic, retain) IBOutlet UILabel *distanceLbl;
#property (nonatomic, retain) IBOutlet UILabel *maxSpeedLbl;
#property (nonatomic, retain) IBOutlet UILabel *currentSpeedLbl;
#property (nonatomic, retain) CLLocationManager *locMgr;
#property (nonatomic, assign) id delegate;
CoreLocationController.m
#synthesize locMgr;
#synthesize delegate = _delegate;
#synthesize distanceLbl,maxSpeedLbl,currentSpeedLbl;
- (id)init {
self = [super init];
if(self != nil) {
self.locMgr = [[CLLocationManager alloc] init];
self.locMgr.delegate = self;
}
return self;
}
- (void)locationChange:(CLLocation *)newLocation:(CLLocation *)oldLocation {
NSTimeInterval difference = [[newLocation timestamp] timeIntervalSinceDate:[oldLocation timestamp]];
double temp_distance = [newLocation getDistanceFrom:oldLocation];
distance += temp_distance;
distanceLbl.text = [NSString stringWithFormat:#"%.2d",distance];
currentSpeed = (temp_distance/difference) * (18.0/5.0);
if (currentSpeed > maxSpeed) {
maxSpeed = currentSpeed;
maxSpeedLbl.text = [NSString stringWithFormat:#"%.2d",maxSpeed];
}
currentSpeedLbl.text = [NSString stringWithFormat:#"%.2d",currentSpeed];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
if([self.delegate conformsToProtocol:#protocol(CoreLocationControllerDelegate)]) {
[self.delegate locationUpdate:newLocation];
[self.delegate locationChange:newLocation :oldLocation];
}
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
if([self.delegate conformsToProtocol:#protocol(CoreLocationControllerDelegate)]) {
[self.delegate locationError:error];
}
}
Related
i want to implement user tracking (running, walking) with GPS (Apple Maps). So when user is walking i want to draw a line on map - realtime.
How can I do that?
I saw one solution here: http://www.raywenderlich.com/21365/introduction-to-mapkit-in-ios-6-tutorial but it works only if you have already point A and B.
Thanks in advance!
Tom
For the first step i prepare the property like this
ViewController.h
#import <MapKit/MapKit.h>
#interface ViewController : UIViewController <CLLocationManagerDelegate, MKMapViewDelegate>
#property (nonatomic, strong) MKMapView *mapView;
#property (nonatomic, strong) MKPolyline* routeLine;
#property (nonatomic, strong) MKPolylineView* routeLineView;
#property (nonatomic, strong) NSMutableArray *trackPointArray;
#property (nonatomic, strong) CLLocationManager *locationManager;
#property (nonatomic, readwrite) MKMapRect routeRect;
#end
then i'm implement like this inside ViewController.m
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
MKMapPoint * pointsArray = malloc(sizeof(CLLocationCoordinate2D)*2);
pointsArray[0]= MKMapPointForCoordinate(oldLocation.coordinate);
pointsArray[1]= MKMapPointForCoordinate(tempNewLocation.coordinate);
routeLine = [MKPolyline polylineWithPoints:pointsArray count:2];
free(pointsArray);
if (tempNewLocation.coordinate.latitude - oldLocation.coordinate.latitude < 1)
{
[[self mapView] addOverlay:routeLine];
}
}
For iOS6 you could try this way instead of the code above :
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *newLocation = [locations objectAtIndex:locations.count - 1];
CLLocation *oldLocation = nil;
if (locations.count > 1)
{
oldLocation = [locations objectAtIndex:locations.count - 2];
}
MKMapPoint * pointsArray = malloc(sizeof(CLLocationCoordinate2D)*2);
pointsArray[0]= MKMapPointForCoordinate(oldLocation.coordinate);
pointsArray[1]= MKMapPointForCoordinate(tempNewLocation.coordinate);
routeLine = [MKPolyline polylineWithPoints:pointsArray count:2];
free(pointsArray);
if (tempNewLocation.coordinate.latitude - oldLocation.coordinate.latitude < 1)
{
[[self mapView] addOverlay:routeLine];
}
}
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
MKOverlayView* overlayView = nil;
self.routeLineView = [[MKPolylineView alloc] initWithPolyline:[self routeLine]];
[[self routeLineView] setFillColor:[UIColor colorWithRed:167/255.0f green:210/255.0f blue:244/255.0f alpha:1.0]];
[[self routeLineView] setStrokeColor:[UIColor colorWithRed:106/255.0f green:151/255.0f blue:232/255.0f alpha:1.0]];
[[self routeLineView] setLineWidth:15.0];
[[self routeLineView] setLineCap:kCGLineCapRound];
overlayView = [self routeLineView];
return overlayView;
}
i hope my answer will help you, Cheers.
how do i use the UISlider to change the zoom value of a MKMapView.
i tried this code but in works not perfectly,
- (IBAction)slideAction:(id)sender
{
span.latitudeDelta = 125*(1-slideValue.value)+0.01;
span.longitudeDelta = 0.001;
region.span = span;
region.center=map.centerCoordinate;
[map setRegion:region animated:TRUE];
}
any suggestions? i think their is no default zoom controller for MKMap?
Note that your longitudeDelta needs to change or it probably won't zoom.
You might find this useful: https://github.com/calabash/calabash-ios-server/blob/master/calabash/Classes/MapKit/MKMapView%2BZoomLevel.m
(I copied most of it from http://troybrant.net/blog/2010/01/set-the-zoom-level-of-an-mkmapview/)
//
// ViewController.m
// MapKitRegion
#import "ViewController.h"
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#import <AddressBook/AddressBook.h>
#interface ViewController () <MKMapViewDelegate>
#property (strong, nonatomic) IBOutlet UITextView *txtAddress;
#property (strong, nonatomic) IBOutlet UIButton *btnGetMap;
#property (strong, nonatomic) IBOutlet UISegmentedControl *segType;
#property (strong, nonatomic) IBOutlet UISlider *slideZoom;
#property (strong, nonatomic) IBOutlet MKMapView *mapView;
#property CLLocationCoordinate2D coord;
- (IBAction)btnGetMapTouched:(id)sender;
- (IBAction)segTypeChanged:(id)sender;
- (IBAction)slideZoomChanged:(id)sender;
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
_mapView.delegate = self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (IBAction)btnGetMapTouched:(id)sender {
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:self.txtAddress.text
completionHandler:^(NSArray *placemarks, NSError *error) {
if (error) {
NSLog(#"Geocode failed with error: %#", error);
return;
}
if(placemarks && placemarks.count > 0) {
CLPlacemark *placemark = placemarks[0];
_coord = placemark.location.coordinate;
_mapView.centerCoordinate = _coord;
[self SetZoom];
}
}];
}
- (IBAction)segTypeChanged:(id)sender {
if (self.segType.selectedSegmentIndex == 0)
_mapView.mapType = MKMapTypeStandard;
else
_mapView.mapType = MKMapTypeSatellite;
}
- (IBAction)slideZoomChanged:(id)sender {
[self SetZoom];
}
- (void) SetZoom {
int meters = self.slideZoom.value * 30000;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance (_coord, meters, meters);
[_mapView setRegion:region animated:NO];
}
#end
I am doing some exercises with delegate, but now I have a problem with a UIView. This is my storyboard
I want to change the color of the UIView with 3 UISliders. The range of UISliders is from 0 to 255.
And this is my code:
ColorField is the UIView custom class
ColorField.h
#import <UIKit/UIKit.h>
#protocol ColorFieldDelegate <NSObject>
-(NSArray *)giveMeColors;
#end
#interface ColorField : UIView
#property (nonatomic , weak) IBOutlet id<ColorFieldDelegate> delegate;
#end
ColorField.m
#import "ColorField.h"
#implementation ColorField
#synthesize delegate = _delegate;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
NSArray *arrayOfColors = [self.delegate giveMeColors];
int red = [[arrayOfColors objectAtIndex:0] intValue];
int green = [[arrayOfColors objectAtIndex:1] intValue];
int blue = [[arrayOfColors objectAtIndex:2] intValue];
NSLog(#"Red --> %d" ,red);
NSLog(#"Green --> %d" ,green);
NSLog(#"Blue --> %d \n\n" ,blue);
self.backgroundColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
}
#end
ColorViewController.h
#import <UIKit/UIKit.h>
#import "ColorField.h"
#interface ColorViewController : UIViewController <ColorFieldDelegate>
#property (nonatomic) IBOutlet ColorField *colorField;
#property (weak, nonatomic) IBOutlet UISlider *redSlider;
#property (weak, nonatomic) IBOutlet UISlider *greenSlider;
#property (weak, nonatomic) IBOutlet UISlider *blueSlider;
#end
ColorViewController.m
#import "ColorViewController.h"
#interface ColorViewController ()
#property (nonatomic) double redQuantity;
#property (nonatomic) double greenQuantity;
#property (nonatomic) double blueQuantity;
#end
#implementation ColorViewController
#synthesize colorField = _colorField;
#synthesize redSlider;
#synthesize greenSlider;
#synthesize blueSlider;
#synthesize redQuantity;
#synthesize blueQuantity;
#synthesize greenQuantity;
- (void)viewDidLoad
{
[super viewDidLoad];
[self.colorField setDelegate:self];
[self.colorField setNeedsDisplay];
self.redQuantity = 125.0;
self.blueQuantity = 125.0;
self.greenQuantity = 125.0;
[self.colorField setNeedsDisplay];
// Do any additional setup after loading the view, typically from a nib.
}
-(ColorField *)colorField
{
if (_colorField == nil) {
_colorField = [[ColorField alloc] init];
}
return _colorField;
}
- (void)viewDidUnload
{
[self setColorField:nil];
[self setRedSlider:nil];
[self setGreenSlider:nil];
[self setBlueSlider:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
-(IBAction)changeRedQuantity:(UISlider *)sender
{
//methods of UISliders
self.redQuantity = [sender value];
[self.colorField setNeedsDisplay];
}
-(IBAction)changeBlueQuantity:(UISlider *)sender
{
self.blueQuantity = [sender value];
[self.colorField setNeedsDisplay];
}
-(IBAction)changeGreenQuantity:(UISlider *)sender
{
self.greenQuantity = [sender value];
[self.colorField setNeedsDisplay];
}
-(NSArray *)giveMeColors
{
NSNumber *redNumber = [NSNumber numberWithDouble:self.redQuantity];
NSNumber *greenNumber = [NSNumber numberWithDouble:self.greenQuantity];
NSNumber *blueNumber = [NSNumber numberWithDouble:self.blueQuantity];
NSArray *array = [[NSArray alloc] initWithObjects:redNumber, greenNumber,blueNumber, nil];
return array;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
#end
BUT...this is the result: It show me only RED, GREEN and BLUE colors without gradation, for example: RGB (255,0,75) is THIS
and not THIS:
I don't know with it can't show me gradation...
Thanks!!
Marco Manzoni
You have to divide your slidervalues by 255.0.
[UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:1.0];
colorWithRed only accepts values 0.0-1.0
I have little problem with my iphone application. I have such classes and interfaces:
CinemaMapAnnotation.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#interface CinemaMapAnnotation : NSObject <MKAnnotation>{
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subtitle;
}
#property (nonatomic, assign) CLLocationCoordinate2D coordinate;
#property (nonatomic, copy) NSString* title;
#property (nonatomic, copy) NSString* subtitle;
-(id)initWithCoordinate:(CLLocationCoordinate2D) c;
#end
CinemaMapAnnotation.m
#import "CinemaMapAnnotation.h"
#implementation CinemaMapAnnotation
#synthesize title, subtitle, coordinate;
-(id)initWithCoordinate:(CLLocationCoordinate2D) c{
self = [super init];
if (self) {
coordinate = c;
}
return self;
}
-(void) dealloc {
self.title = nil;
self.subtitle = nil;
[super dealloc];
}
#end
CinemasMapController.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import "Cinema.h"
#import "CinemaMapAnnotation.h"
#import "PopcornuaAppDelegate.h"
#interface CinemasMapController : UIViewController <MKMapViewDelegate, MKReverseGeocoderDelegate> {
MKMapView *mapView;
MKReverseGeocoder *reverseGeokoder;
}
#property (nonatomic, retain) IBOutlet MKMapView *mapView;
#property (nonatomic, retain) IBOutlet MKReverseGeocoder *reverseGeokoder;
#end
CinemasMapController.m
#import "CinemasMapController.h"
#implementation CinemasMapController
#synthesize mapView, reverseGeokoder;
...
#pragma mark - Map Anotation
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id)annotation
{
static NSString* MyIdentifier = #"CinemaMapAnotation";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:MyIdentifier];
if (!pinView)
{
MKPinAnnotationView* pinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:MyIdentifier] autorelease];
pinView.draggable = NO;
pinView.animatesDrop = NO;
pinView.enabled = YES;
} else {
pinView.annotation = annotation;
}
if(annotation != mapView.userLocation){
pinView.pinColor = MKPinAnnotationColorRed;
pinView.canShowCallout = YES;
// Add a detail disclosure button to the callout.
pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.userInteractionEnabled = YES;
} else {
pinView.pinColor = MKPinAnnotationColorGreen;
}
return pinView;
}
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
NSLog(#"Not show button, so not work");
}
...
#end
My problem is, what all show and work, except not show rightCalloutAccessoryView button. mapView connected and have delegete to CinemasMapController on iphone view (also I try [mapView setDelegate:self]). So what I do wrong?
P.S. Code with line
pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
execute - checked by NSLog.
Here how its look like - no button:
In viewForAnnotation, in the if (!pinView) block, a new local pinView variable is being declared instead of getting assigned to the outer variable.
As a result, the outer pinView variable never gets set (stays nil) and so the map view creates the default annotation view which is what you see.
Hey Guys I have the following simple Code :
WhereAmIViewController.h
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#interface WhereAmIViewController : UIViewController <CLLocationManagerDelegate> {
CLLocationManager *locationManager;
CLLocation *startingPoint;
IBOutlet UILabel *latitudeLabel;
IBOutlet UILabel *longitudeLabel;
IBOutlet UILabel *magneticHeading;
}
#property (retain, nonatomic) CLLocationManager *locationManager;
#property (retain, nonatomic) CLLocation *startingPoint;
#property (retain, nonatomic) UILabel *latitudeLabel;
#property (retain, nonatomic) UILabel *longitudeLabel;
#property (nonatomic, retain) UILabel *magneticHeading;
#end
WhereAmIViewController.m
#import "WhereAmIViewController.h"
#implementation WhereAmIViewController
#synthesize locationManager;
#synthesize startingPoint;
#synthesize latitudeLabel;
#synthesize longitudeLabel;
#synthesize magneticHeading;
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
NSString *magneticstring = [[NSString alloc] initWithFormat:#"%0.0f°",
newHeading.magneticHeading];
magneticHeading.text = magneticstring;
[magneticstring release];
}
#pragma mark -
-(void)viewDidLoad
{
self.locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[locationManager release];
[startingPoint release];
[latitudeLabel release];
[longitudeLabel release];
[super dealloc];
}
#pragma mark -
#pragma mark CLLocationManagerDelegate Methods
-(void)locationManager:(CLLocationManager *)manger
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
if(startingPoint == nil)
self.startingPoint = newLocation;
NSString *latitudeString = [[NSString alloc] initWithFormat:#"%g",newLocation.coordinate.latitude];
latitudeLabel.text = latitudeString;
[latitudeString release];
NSString *longitudeString = [[NSString alloc] initWithFormat:#"%g",newLocation.coordinate.longitude];
longitudeLabel.text = longitudeString;
[longitudeString release];
}
-(void)longitudeManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
NSString *errorType = (error.code ==kCLErrorDenied)?#"Access Denied":#"Unknown Error";
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Error Getting Location!" message:errorType delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
#end
So that's what I am displaying on screen .. I just wanted to know how get these 3 labels as an overview for the camera . I have refered to http://www.musicalgeometry.com/archives/821
But having trouble as mine is "View Based app" and the tutorial uses a "Windows Based app" template .. How can I configure this code to get the camera overlay ?
P.S: The background color is : noColor (transparent ).
Thank You !
You need a UIImagePickerController, and then you create a UIView and add your 3 labels in appropriate locations in subview then you can call, picker.cameraOverlayView = YOUR_UI_VIEW and picker.showsCameraControls = NO. If you already set up everything inside your WhereAmIViewController then you can do picker.cameraOverlayView = whereAmIVC.view