在iphone中找到当前位置

时间:2011-05-09 11:47:36

标签: iphone objective-c core-location cllocationmanager

尝试在当前位置添加注释当我需要任何数量的注释但它的工作可以帮助我 我试试这段代码

 - (CLLocationCoordinate2D)coordinate;
{
    CLLocationCoordinate2D theCoordinate;
    theCoordinate.latitude =MKUserLocation.latitude;          //37.786996;// Here we have to change the with current location  
    theCoordinate.longitude = MKUserLocation.longitude;
    return theCoordinate; 
}

3 个答案:

答案 0 :(得分:1)

使用CLLocationManagerDelegate方法

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation

答案 1 :(得分:1)

[map setShowsUserLocation:TRUE];

map是MKMapView的对象。

答案 2 :(得分:0)

使用此委托方法

-(void)locationManager:(CLLocationManager *)manager
        didUpdateToLocation:(CLLocation *)newLocation
               fromLocation:(CLLocation *)oldLocation {

        if (userLocation_) {
            [userLocation_ release];
        }
        userLocation_ = [newLocation retain];
    }