Upload
simon-kim
View
685
Download
0
Embed Size (px)
Citation preview
iOS App Development
Q.1 Tracking Locationhttp://iosappdev.co.kr
13년 2월 28일 목
CLLocationManager
Core Location Framework
<CoreLocation/CoreLocation.h>
Interface for delivering Location Update
13년 2월 28일 목
CLLocationManagerSteps to use: Simplest Example
Instantiate - [[... alloc] init];
Setup desiredAccuracy @property
Implement and Assign a Delegate
delegate @property
CLLocationManagerDelegate
[... startUpdatingLocation]
Receive Update: CLLocation object
13년 2월 28일 목
CLLocationManagerInitialize and Start Updating
@interface ......@property (nonatomic, strong) CLLocationManager *locationManager;...@end// in a method // Instantiate
self.locationManager = [[CLLocationManager alloc] init]; // Setup Delegate: See Next Slide self.locationManager.delegate = self; // Setup Accuracy CLLocationAccuracy accuracy = kCLLocationAccuracyNearestTenMeters; self.locationManager.desiredAccuracy = accuracy; // Start! [self.locationManager startUpdatingLocation];...
13년 2월 28일 목
CLLocationManagerSetup a Delegate
@interface KMUViewController () <CLLocationManagerDelegate>......@end// in a method, before starting update ... self.locationManager.delegate = self;...
#pragma mark - CLLocationManagerDelegate- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ CLLocation *location = [locations lastObject]; CLLocationDegrees lat = location.coordinate.latitude; CLLocationDegrees lon = location.coordinate.longitude; // ... self.textField.text = [location description];}
13년 2월 28일 목
Demo
/ Demos / Day2 / Demo / Location /
https://github.com/iosappdev/KMU2013
13년 2월 28일 목
Testing in Simulator
http://iosappdev.co.kr
13년 2월 28일 목