【发布时间】:2015-06-05 20:09:14
【问题描述】:
当我输入以下代码并在模拟器上运行并将位置设置为“City Run”时,它不会记录任何内容。我不知道我做错了什么。
.h
#import <CoreLocation/CoreLocation.h>
@interface ViewController : UIViewController <UITextFieldDelegate,CLLocationManagerDelegate> {
CLLocationManager *locMgr;
}
@property (nonatomic, retain) CLLocationManager *locMgr;
@property NSInteger speed;
.m
@synthesize locMgr;
- (void)viewDidLoad {
[super viewDidLoad];
self.locMgr = [[CLLocationManager alloc] init];
self.locMgr.delegate = self;
self.locMgr.desiredAccuracy = kCLLocationAccuracyBest;
[self.locMgr startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
self.speed = roundf([newLocation speed]);
NSLog(@"speed: %ld", (long)self.speed);
}
你看到我遗漏了什么吗?
【问题讨论】:
标签: ios objective-c location core-location