得到一个;缺少方法声明的上下文“;在xcode中实现地图搜索栏

得到一个;缺少方法声明的上下文“;在xcode中实现地图搜索栏,xcode,Xcode,当我在viewcontroller中实现此代码时,我收到一个错误,上面写着“缺少方法声明的上下文”。m: - (void)searchBarSearchButtonClicked:(UISearchBar *)theSearchBar { [theSearchBar resignFirstResponder]; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:

当我在viewcontroller中实现此代码时,我收到一个错误,上面写着“缺少方法声明的上下文”。m:

- (void)searchBarSearchButtonClicked:(UISearchBar *)theSearchBar {
    [theSearchBar resignFirstResponder];
    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    [geocoder geocodeAddressString:theSearchBar.text completionHandler:^(NSArray *placemarks,      NSError *error) {
        //Error checking

        CLPlacemark *placemark = [placemarks objectAtIndex:0];
        MKCoordinateRegion region;
        region.center.latitude = placemark.region.center.latitude;
        region.center.longitude = placemark.region.center.longitude;
        MKCoordinateSpan span;
        double radius = placemark.region.radius / 1000; // convert to km

        NSLog(@"[searchBarSearchButtonClicked] Radius is %f", radius);
        span.latitudeDelta = radius / 112.0;

        region.span = span;

        [theMapView setRegion:region animated:YES];
    }];
}

这个错误出现在这个方法的哪一行?它发生在“-(void)searchBarSearchButtonClicked:(UISearchBar*)搜索栏{”是
@implementation…@end
块中定义的方法?不,不是…但是当我在实现中添加它时,它仍然会弹出相同的错误。