2012-01-06 32 views
0

当我点击的PIN正确的标注,我想移动到名为DetailsThemes一个新的视图控制器,但是,当我这样做:按另一种观点认为,当点击rightCalloutAccessoryView

-(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'? 

虽然detailsThemesDetailsThemes一个实例是一个UIViewController类,另外,在我的课我没有调用像THI文件的顶部DetailsThemes@class DetailsThemes; S:

#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

你看过错误信息吗?阅读两遍,它有解释。你必须声明@property的detailsThemes或直接访问伊娃。 – 2012-01-06 13:34:30

+0

我做了,好吧,现在我得到了一切运行良好,但是,当我点击PIN的正确信息按钮,我什么也没有,细节视图不收费。 – Malloc 2012-01-06 13:47:39

+0

CalloutAccessoryControlTapped实际上是否被调用?确保放入一个NSLog或断点。 – Anna 2012-01-06 13:52:18

回答

0

在你ViewDidLoad方法,你必须先分配你DetailsThemes,然后在你的电话了使用它。如果你仍然没有成功,那么请张贴你的电话代码.OutAccessoryView