views:

789

answers:

1

Hello all:

I want to add a new view on a rightcalloutaccessoryview button press. I currently have the functionality for dropping a pin on the map. A callout (MKAnnotation) with a title, subtitle, and chevron loads when I tap the pin. When I tap the chevron (rightcalloutaccessoryview) I want another view to pop up showing more information at this point. Right now, the chevron tap does nothing. This is what I have:

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

I have verified that this action method does get called upon pressing the chevron. Unfortunately, I can't get it to pull up a new view. If anyone knows what I'm doing wrong, please let me know. I'm in a bit of a pinch...

Thanks!

Thomas

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

}

It was missing this one statement:

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

I would like to find another way so I don't have to have that magic number (99999) in there (plus, it seems kinda immature...). I'm not TOO worried about it, because it works though.

I got my help from the Apple Developer Forums, here.

Thomas