我正在尝试编译以下代码,但是在指定的行上出现错误:
#pragma mark CLLocationManagerDelegate Methods
//**error expected identifier before "{" token**
-(void)locationmanager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)
{
MKCoordinateSpan span;
span.latitudeDelta = 0,2;
span.longitudeDelta = 0,2;
MKCoordinateRegion region;
region.span = span;
region.center = newLocation.coordinate;
[viewController.mapview setRegion:region animated:YES];
viewController.mapview.showsUserLocation = YES;
viewController.latitude.text =[NSString stringWithFormat:@"Xf", newLocation.coordinate.latitude]
viewController.longitude.text =[NSString stringWithFormat:@"Xf", newLocation.coordinate.longitude]
}
@end
我该如何解决这个问题?
答案 0 :(得分:4)
在第一行的尾随{
之前需要一个参数名称,例如
... fromLocation:(CLLocation *)fromLocation {
答案 1 :(得分:2)
是的,正如它所说,你有
-(void)locationmanager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)
{
你错过了来自位置名称的论点,事情应该是
-(void)locationmanager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)someName
{
答案 2 :(得分:0)
你在最后两个赋值语句中缺少分号。
答案 3 :(得分:0)
将0,2
替换为0.2
(带点),并在最后两次通话结束时添加;
。