我想在rightcalloutaccessoryview按钮按下添加一个新的视图。我现在有在地图上放置图钉功能。标注(MKAnnotation)与标题,字幕和人字形负载时,我点击了脚。当我点击了雪佛龙(rightcalloutaccessoryview)我想另一种观点认为弹出显示在这一点上的更多信息。眼下,人字形水龙头什么都不做。这是我有:

-(IBAction)showInfo:(id)sender 
{     
     int calloutButtonPressed = ((UIButton *)sender).tag;
     if(calloutButtonPressed < 99999)
     {
          if(self.DetailView == nil)
          {
               DetailViewController *tmpViewController = [[UIViewController alloc] initWithNibName:@"DetailView" bundle:nil];
               self.DetailView = tmpViewController;
               [tmpViewController release];
          }

          if (calloutButtonPressed == 1) 
          {
                         // Using the debugger, I found that calloutButtonPressed is equal to 0 when the button is pressed.
                         // So I'm not sure what the point of this method is...
                }
          self.DetailView.title = @"Title";
     }
 }

我已经验证了这种操作方法并获得在敲击字形调用。不幸的是,我不能把它拉了一个新的视角。如果有人知道我在做什么错了,请让我知道。我在一个有点捏...

谢谢!

托马斯

有帮助吗?

解决方案

    -(IBAction)showInfo:(id)sender 
{   
     int calloutButtonPressed = ((UIButton *)sender).tag;
     if(calloutButtonPressed < 99999)
     {
          if(self.detailView == nil)
          {
               DetailViewController *tmpViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
               self.detailView = tmpViewController;
               [tmpViewController release];
          }

          [self.navigationController pushViewController:self.detailView animated:YES];

          if (calloutButtonPressed == 0) 
          {
               // TRP - I inserted my view atIndex:99999 to ensure that it gets placed in front of all windows
               // TODO: figure a better way to do this
               [self.view insertSubview:detailView.view atIndex:99999];
          }
          self.detailView.title = @"Title";
     }

}

这是缺少这一个语句:

[self.view insertSubview:detailView.view atIndex:99999];

我想另谋出路,所以我不必有一个神奇的数字(99999)在那里(加,似乎有点幼稚...)。我不是太担心,因为它的工作原理,但。

我得到我的帮助从苹果开发者论坛,这里

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top