теперь есть одна переменная, которую я хочу видеть только в первом представлении, но по-прежнему иметь эффект во втором представлении. Это будет специальный маркер, положение которого можно будет изменить по сравнению с первым представлением. (обновление GPS в фоновом режиме происходит только в первом представлении), а изменения появятся во втором представлении.
поэтому я собираюсь сделать следующее:
р>
Код: Выделить всё
@implementation WhereAmIView
{
RMMarker *iAmHere;
void (^setupMap)(RMMapView*);
}
- (void) setup {
//__block RMMarker *_iAmHere = iAmHere;
setupMap = ^(RMMapView *mapViewBlock){
if(!iAmHere)
iAmHere = [[RMMarker alloc]initWithUIImage:[UIImage imageNamed:@"marker-red.png"] anchorPoint:CGPointMake(0.5, 1.0)];
//there is a bunch of other stuff i have omitted here, but the important bit is above this comment
[iAmHere setTextForegroundColor:[UIColor blueColor]];
[iAmHere changeLabelUsingText:@"You are Here"];
[markerManager addMarker:iAmHere AtLatLong:appDelegate.currentLocation.coordinate]; //dont worry about this stuff, just put it here to show that stuff is happening
}
setupMap(mapView);
}
- (IBAction)enlargeMap:(id)sender {
MainViewController *mainViewController = (MainViewController*)[self viewController];
FullScreenMapViewController *fsmvc = [[FullScreenMapViewController alloc] initWithCenter:CLLocationCoordinate2DMake(0, 0) andMap:@"tokai2.db"];
fsmvc->setupMap = setupMap; //this gets run in its viewDidAppear effectively
[mainViewController presentModalViewController:fsmvc animated:true];
}
или, может быть, есть лучший способ сделать это полностью ...
Подробнее здесь: https://stackoverflow.com/questions/158 ... -good-idea