当我点击PIN上的右侧标注时,我想移动到名为DetailsThemes
的新视图控制器,但是,当我这样做时:
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
[self.navigationController pushViewController:self.detailsThemes animated:YES];
}
我收到了这个错误:
Property detailsThemes not found on object of type 'ViewController *';
did you mean to access ivar 'detailsThemes'?
尽管detailsThemes
是DetailsThemes
的一个实例,它是一个UIViewController类,同样,在我的课程中,我确实调用了DetailsThemes
类,其中@class DetailsThemes;
位于顶部。像这样的文件:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@class DetailsThemes;
@interface ViewController : UIViewController<MKMapViewDelegate>
{
DetailsThemes * detailsThemes;
}
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
@end
修改
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"calloutAccessoryControlTapped: %@",view.annotation);
[self.navigationController pushViewController:self.detailsThemes animated:YES];
}
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation {
static NSString *identifier = @"ManageAnnotations";
MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [map dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
annotationView.enabled = YES;
[annotationView setAnimatesDrop:YES];
annotationView.canShowCallout = YES;
//annotationView.pinColor = ((ManageAnnotations *)annotation).pinColor;
annotationView.rightCalloutAccessoryView=[UIButton buttonWithType:UIButtonTypeInfoLight];
return annotationView;
}
答案 0 :(得分:0)
在ViewDidLoad
方法中,您必须首先分配DetailsThemes
,然后在通话中使用它。如果您还没有成功,请发布callOutAccessoryView的代码