注释详细信息视图未加载到 Mapkit 中
我有一张地图,根据用户位置显示各种图钉。我可以毫无问题地查看引脚和标注。当我按下详细信息披露按钮时,我的 MapDetailInfo 不会加载。这是一些代码。
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
// Specify which MKPinAnnotationView to use for each annotation.
MKPinAnnotationView *businessListingPin = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier: @"BLPin" ];
if (businessListingPin == nil)
{
businessListingPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"BLPin"];
}
else
{
businessListingPin.annotation = annotation;
}
// If the annotation is the user's location, don't show the callout and change the pin color
if(annotation == self.mapView.userLocation)
{
businessListingPin.canShowCallout = NO;
businessListingPin.pinColor = MKPinAnnotationColorRed;
}
else
{
businessListingPin.canShowCallout = YES;
businessListingPin.pinColor = MKPinAnnotationColorPurple;
businessListingPin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
}
return businessListingPin;
}
- (void)mapView:(MKMapView *)mapView
annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
{
MapDetailInfo *abc = [[MapDetailInfo alloc]init];
UINavigationController *nav = [[UINavigationController alloc] init];
[nav pushViewController:abc animated:YES];
}
不确定这是否重要,但这是选项卡栏应用程序的一部分。任何帮助将不胜感激。谢谢!
I have a Map that shows various pins based on the users location. I can view the pins and there callouts without a problem. When I press the detail disclosure button, my MapDetailInfo does not load. Here is some of the code.
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
// Specify which MKPinAnnotationView to use for each annotation.
MKPinAnnotationView *businessListingPin = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier: @"BLPin" ];
if (businessListingPin == nil)
{
businessListingPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"BLPin"];
}
else
{
businessListingPin.annotation = annotation;
}
// If the annotation is the user's location, don't show the callout and change the pin color
if(annotation == self.mapView.userLocation)
{
businessListingPin.canShowCallout = NO;
businessListingPin.pinColor = MKPinAnnotationColorRed;
}
else
{
businessListingPin.canShowCallout = YES;
businessListingPin.pinColor = MKPinAnnotationColorPurple;
businessListingPin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
}
return businessListingPin;
}
- (void)mapView:(MKMapView *)mapView
annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
{
MapDetailInfo *abc = [[MapDetailInfo alloc]init];
UINavigationController *nav = [[UINavigationController alloc] init];
[nav pushViewController:abc animated:YES];
}
Not sure if it matters or not, but this is part of a tab bar application. Any help would be much appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在实例化一个 UINavigationController (
UINavigationController *nav = [[UINavigationController alloc] init];
),然后将新的 VC 推入其中,但您从未将该导航控制器添加到当前视图堆栈中。仅调用init
不会将该导航控制器添加到堆栈中。创建
UITabController
时,您可以为每个选项卡创建并使用导航控制器。然后将新的 VC 推送到该导航控制器上。希望这有帮助。
** 编辑
如果您已经拥有所有选项卡的导航控制器,请将代码更改为:
You are instantiating a UINavigationController (
UINavigationController *nav = [[UINavigationController alloc] init];
) and then pushing your new VC onto that, but you never add that nav controller to the current view stack. Simply callinginit
doesn't add that navigation controller to the stack.When you create your
UITabController
, you can create + use a navigation controller for each tab. Then you push the new VC onto that navigation controller.Hope this helps.
** edit
If you've already got navigation controllers for all of your tabs, change your code to this: