2
我打算在iPhone上進行GPS定位。你能告訴我關於GPS的信息(代表,方法等)。iPhone sdk位置更改通知
我打算在iPhone上進行GPS定位。你能告訴我關於GPS的信息(代表,方法等)。iPhone sdk位置更改通知
聲明CLLocation
CLLocationManager *locManager;
的位置經理在函數
self.locManager = [[CLLocationManager alloc] init];
locManager.delegate = self;
locManager.desiredAccuracy = kCLLocationAccuracyBest;
[locManager startUpdatingLocation]; // This Method will call the didUpdateToLocation Delegate
[locManager stopUpdatingLocation]; //This Methods stops the GPS from updating
位置管理委託
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
//Do actions when the GPS is Updating
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"Error in GPS: %@",error);
}
不要忘記,包括CLLocationManagerDelegate在.h文件中,並添加CoreLocation框架到您的項目
查閱CLLocationManager
和CLLocationManagerDelegate
的文檔。如果你仍然有特定的問題,那就回來問問他們。
感謝兄弟... – Klose 2010-11-23 13:42:31