我想在rightcalloutaccessoryview按钮上添加新视图。我目前有在地图上删除图钉的功能。点击引脚时,标题,副标题和V形符号的标注(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";
}
}
我已经确认按下V形符号时会调用此动作方法。不幸的是,我无法得到它来提出一个新观点。如果有人知道我做错了什么,请告诉我。我有点紧张......
谢谢!
托马斯
答案 0 :(得分: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";
}
}
缺少这一陈述:
[self.view insertSubview:detailView.view atIndex:99999];
我想找到另一种方式,所以我不必拥有那个神奇的数字(99999)(另外,它似乎有点不成熟......)。我并不担心,因为它有效。
我从Apple开发者论坛获得了我的帮助,here。