1

我是 iOS 开发的初学者,我的应用程序目前有两个独立的控制器 - mapViewController(左侧)和 photoViewController(右侧),如下所示:

图片链接

我在地图上添加了一些注释,每个注释都包含一张照片(在标注的右侧配件上显示为小尺寸)。

我的想法是,如果用户点击左侧的附件,它是一个蓝色的细节按钮,完整尺寸的照片应该出现在右侧。

我尝试用委托来实现它:

在地图视图控制器中:

-(void)mapView:(MKMapView *)mapView 
annotationView:(MKAnnotationView *)aView 
calloutAccessoryControlTapped:(UIControl *)control
{
    KCFlickPhotoAnnotation *fpa = (KCFlickPhotoAnnotation *) aView.annotation;
    self.photoDictionary = fpa.photo;
    [self photoDictionaryDelegate];
}

-(void)photoDictionaryDelegate
{
    NSDictionary *photoDictionary = self.photoDictionary;
    [spDelegate setPhotoDictionary:photoDictionary in:self];
    //NSLog(@"button pressed");
}

在 photoViewController.m 中:

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    mapVC.spDelegate = self;
    [mapVC photoDictionaryDelegate];
}

-(void)setPhotoDictionary:(NSDictionary *)photoDictionary 
                       in:(KCMapViewController *)mapViewController
{
    self.photo = photoDictionary;
    NSLog(@"%@",self.photo); // LINE A
}

在 photoViewController.h 中:

@interface KCPhotoViewController : UIViewController <setPhotoDelegation>
{
    KCMapViewController *mapVC;
}

LINE A不行,好像是photoDictionary不能到达photoViewController,怎么解决这个问题?

4

0 回答 0