开发者

Adding a new view on rightcalloutaccessoryview button press

开发者 https://www.devze.com 2022-12-19 17:01 出处:网络
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 loa

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


    -(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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号