0

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";
     }
 }

シェブロンを押すと、このアクション メソッドが呼び出されることを確認しました。残念ながら、新しいビューを表示することはできません。誰かが私が間違っていることを知っているなら、私に知らせてください。ちょっとピンチで…

ありがとう!

トーマス

4

1 に答える 1

0
    -(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";
     }

}

次の 1 つのステートメントが欠落していました。

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

別の方法を見つけて、そこにそのマジックナンバー(99999)を入れる必要がないようにしたいと思います(さらに、それはちょっと未熟なようです...)。私はそれについてあまりにも心配していません。

ここにある Apple Developer Forums から助けを得ました。

于 2010-02-19T22:24:28.393 に答える