【发布时间】:2013-07-02 07:22:19
【问题描述】:
我现在想弄清楚,我应该如何使用注释按钮进行切换 到另一个地图视图。我正在开发的应用程序使用 MapBox - 地图。我检查了例子 由他们提供,但始终可以在两个地图之间以编程方式切换 通过标签栏(我不想使用这种情况)。 我正在使用故事板,我理解它很好,应该如何制作segue 在界面生成器中,但我认为我没有使用以编程方式集成的 地图视图上的按钮。我在两个头文件中都启动了“id”,并在 身份检查员也是如此。
这是代码的一部分,我在其中实现了带有注释的 RMMMapView 主视图控制器 - 视图控制器,它完美地工作:
- (void)viewDidLoad{
[super viewDidLoad];
RMMapBoxSource *onlineSource = [[RMMapBoxSource alloc] initWithMapID:(([[UIScreen mainScreen] scale] > 1.0) ? kRetinaMapID : kNormalMapID)];
_mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:onlineSource];
_mapView.tileSource = [[RMMapBoxSource alloc] initWithMapID:(([[UIScreen mainScreen] scale] > 1.0) ? kRetinaMapID : kNormalMapID)];
_mapView.centerCoordinate = CLLocationCoordinate2DMake(0,0);
_mapView.adjustTilesForRetinaDisplay = YES;
_mapView.zoom = 4;
_mapView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:_mapView];
_mapView.showsUserLocation = YES;
[_mapView setConstraintsSouthWest:[_mapView.tileSource latitudeLongitudeBoundingBox].southWest
northEast:[_mapView.tileSource latitudeLongitudeBoundingBox].northEast];
RMPointAnnotation *annotation = [[RMPointAnnotation alloc] initWithMapView:_mapView
coordinate:_mapView.centerCoordinate andTitle:@"Hello, world!"];
[_mapView addAnnotation:annotation];
}
这是我尝试从 ViewController - 主 ViewController 调用 LowContentMap viewController 的部分:
- (void) prepareForSegue:(UIStoryboardSegue *) segue sender:(id) sender {
if ([segue.identifier isEqualToString:@"Hello, world!"]) {
//LowContentMap *lowContentMap = segue.destinationViewController;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];
LowContentMap *lowContentMap = [storyboard instantiateViewControllerWithIdentifier:@"lowContentMap"];
lowContentMap.lcm = _vc;
}}
这是代码的一部分,应该填写:
- (void)mapView:(RMMapView *)mapView annotationView:(RMPointAnnotation *)annotation calloutAccessoryControlTapped:(UIControl *)control{
[self performSegueWithIdentifier:@"ShowSomeViewController" sender:annotation];
}
如果有人能尝试解决问题,那就太好了。 我在以下位置关注了 Noa 和 Kronos 之间的讨论: Setting up a detail view controller using a segue 但我仍然认为,带有“id”的部分是我做错的事情。提前致谢。
【问题讨论】:
标签: ios annotations storyboard uistoryboardsegue mapbox