【问题标题】:push a view from calloutAccessoryControlTapped从 calloutAccessoryControlTapped 推送视图
【发布时间】:2014-04-06 23:35:07
【问题描述】:

我正在尝试从我的 mapView 中的标注推送视图。以下代码似乎不起作用。非常感谢任何帮助。

谢谢

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
   NSLog(@"Tapped Callout");
   srPlayAudio *SrPlayAudio = [[srPlayAudio alloc] initWithNibName:@"nib" bundle:nil];
   SrPlayAudio.fileName = [[view annotation]title];
   [self.navigationController pushViewController:SrPlayAudio animated:YES];
}

只要触摸标注,控制台就会打印 Tapped Callout。我看不出 calloutAccessoryControlTapped 方法有任何问题。

【问题讨论】:

  • 您的新视图真的来自名为“nib”的 nib 文件吗?您是否查看过调试器以确保 srPlayAudio 不为零?你有没有在SrPlayAudioviewDidLoad方法中下断点?
  • 我的导航控制器是零。我没有注意到这一点。我刚刚解决了这个问题。作为该网站的新手,我现在无法发布答案。一旦我有机会这样做,我就会这样做。谢谢@Paulw11 的帮助。

标签: ios ios7 uiviewcontroller mapkit


【解决方案1】:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
  NSLog(@"Tapped Callout");
  srPlayAudio *SrPlayAudio = [[srPlayAudio alloc] init];
  SrPlayAudio.fileName = [[view annotation]title];
  UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:SrPlayAudio];
  navController.navigationBarHidden = NO;
  [self presentViewController:navController animated:YES completion:^{

}];

}

看来我误解了 UINavigationController。导航控制器为空。上面的代码运行良好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-13
    相关资源
    最近更新 更多