ViewController 未在 Google 地图 didTapMarker 方法上显示 - iOS
ViewController not showing on Google Map didTapMarker method - iOS
我有一个 DetailViewController
,当用户点击 mapView_
上的 marker
时会显示。最初我加载 VC 并将其设置为隐藏,当用户点击 marker
时,我会加载 VC 中的值并显示它。但它没有发生。这是我的代码。
@property (strong, nonatomic) GMSMapView *mapView;
- (void)viewDidLoad
{
[super viewDidLoad];
_whisperDetailView.hidden = YES;
[_whisperDetailView initlize];
_whisperDetailView.viewController = self;
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
}
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker
{
_detailView.whisper = marker.userData;
_detailView.hidden = NO;
return YES;
}
故事板快照:
有趣的是,我之前使用过 Mapbox
,并且在它的 didSelectAnnotation
函数中做了完全相同的事情,一切都运行良好。我最近不得不切换到 Google 地图,现在它不起作用了。
感谢任何帮助。谢谢。
好的,我现在可以使用了!为陷入相同情况的其他人发布答案:
我改变了添加 mapView_
的方式。我没有在 viewDidLoad
中分配 self.view = mapView
,而是将 mapView
作为我的主 view
的子视图插入,如下所示:
mapView_ = [GMSMapView mapWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) camera:camera];
[self.view insertSubview:mapView_ atIndex:0];
唉!现在一切都像魅力一样!当我点击一个标记时,我的 DetailViewController
会以适当的大小显示,正如我在情节提要中设置的那样。
我有一个 DetailViewController
,当用户点击 mapView_
上的 marker
时会显示。最初我加载 VC 并将其设置为隐藏,当用户点击 marker
时,我会加载 VC 中的值并显示它。但它没有发生。这是我的代码。
@property (strong, nonatomic) GMSMapView *mapView;
- (void)viewDidLoad
{
[super viewDidLoad];
_whisperDetailView.hidden = YES;
[_whisperDetailView initlize];
_whisperDetailView.viewController = self;
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
}
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker
{
_detailView.whisper = marker.userData;
_detailView.hidden = NO;
return YES;
}
故事板快照:
有趣的是,我之前使用过 Mapbox
,并且在它的 didSelectAnnotation
函数中做了完全相同的事情,一切都运行良好。我最近不得不切换到 Google 地图,现在它不起作用了。
感谢任何帮助。谢谢。
好的,我现在可以使用了!为陷入相同情况的其他人发布答案:
我改变了添加 mapView_
的方式。我没有在 viewDidLoad
中分配 self.view = mapView
,而是将 mapView
作为我的主 view
的子视图插入,如下所示:
mapView_ = [GMSMapView mapWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) camera:camera];
[self.view insertSubview:mapView_ atIndex:0];
唉!现在一切都像魅力一样!当我点击一个标记时,我的 DetailViewController
会以适当的大小显示,正如我在情节提要中设置的那样。