问题
Hy Guys, I have a MapperViewController
@interface MapperViewController : UIViewController <MKMapViewDelegate>
{
MKMapView *mapView;
}
@property (nonatomic, retain) IBOutlet MKMapView *mapView;
@end
In the .m file I can add annotations on a MapView after creating an object (ofc I have a MyAnnotation class)
MyAnnotation *and = [[MyAnnotation alloc] init];
and.name = @"name";
and.subtitle = @"subtitle";
and.coordinate = CLLocationCoordinate2DMake(10.123,10.123);
[mapView addAnnotation:and];
I have another object in another class called RootViewController where I added the values above.(ofc I have a Firma class)
firmenArray = [[NSMutableArray alloc] init];
Firma * aFirma = [[Firma alloc] init];
aFirma.title = @"title";
aFirma.boxOfficeGross = [NSNumber numberWithInt: 200000000];
aFirma.summary = @"summary";
aFirma.name = @"name";
aFirma.subtitle = @"subtitle";
aFirma.coordinate = CLLocationCoordinate2DMake(10.123,10.123);
[mapView addAnnotation:aFirma];
[firmenArray addObject: aFirma];
[aFirma release];
What I want to do is call the [mapView addAnnotation:aFirma]; within this view controller. I have more functions in the MapperViewController which call "mapView", so it have to stay there.
MB someone of u can help me Thank you
回答1:
Why not try make MKMapView a member variable of your RootViewController?
Or, you are also welcome in Object-C to set a delegate hierarchy so that your RootViewController and MapperViewController can communicate in a parent-child way.
来源:https://stackoverflow.com/questions/4486084/call-outlet-of-another-view-controller