在IOS的地图项目中,做了一个定制的地图标注AnnotationView,里面点击会跳出一个callout(customer),在这个callout中放置了两个button,一个是导航的button已经实现,但是详细信息这一个button则无法跳转到详细的UIView页面,哪位大拿有招?
button的创建:
在CustomerAnnotationView.m
return;
} if (selected) if (self.calloutView == nil)
{
self.calloutView = [[CustomCalloutView alloc] initWithFrame:CGRectMake(0, 0, kCalloutWidth, kCalloutHeight)];
self.calloutView.center = CGPointMake(CGRectGetWidth(self.bounds) / 2.f + self.calloutOffset.x,
-CGRectGetHeight(self.calloutView.bounds) / 2.f + self.calloutOffset.y);
}
self.calloutView.title = self.annotation.title;
self.calloutView.subtitle= self.aannotation.subtitle;
self.calloutView.threetitle=self.aannotation.threetitle;
self.calloutView.fourtitle=self.aannotation.fourtitle;
self.leftCalloutAccessoryView.frame=CGRectMake(0, 0, 100, 25);
UIButton *Button=[UIButton buttonWithType:(UIButtonTypeRoundedRect)];
[Button setTitle:@"详细信息" forState:(UIControlStateNormal)];
[Button setTitle:@"转向详细" forState:UIControlStateHighlighted];
Button.frame=CGRectMake(0, 0, 100, 25);
// button.tag=(int)_projectMapInfo.pro_areaid;
[Button addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)];
//标题左视图
[self.calloutView.portraitView addSubview: Button];
// [self.calloutView.portraitView addSubview: self.leftCalloutAccessoryView]; UIButton *rightbutton=[UIButton buttonWithType:(UIButtonTypeRoundedRect)];
[rightbutton setTitle:@"导航去" forState:(UIControlStateNormal)];
[rightbutton setTitle:@"导航中" forState:UIControlStateHighlighted];
rightbutton.frame=CGRectMake(0, 0, 100, 25);
// button.tag=(int)_projectMapInfo.pro_areaid;
[rightbutton addTarget:self action:@selector(rightbuttonAction) forControlEvents:(UIControlEventTouchUpInside)];
//标题左视图
[self.calloutView.rightimageView addSubview:rightbutton];
// [self.calloutView.rightimageView addSubview:self.rightCalloutAccessoryView]; [self addSubview:self.calloutView];
} [self.calloutView removeFromSuperview];
} [super setSelected:selected animated:animated];在button点击后的,函数为:
-(void)buttonAction:(id)sender
{
NSLog(@"详细信息去");
CPlistItem *item = self.aannotation.item;
detailViewController *controller1 = [[detailViewController alloc]initWithObject:item];
controller1.view.backgroundColor = [UIColor whiteColor];
controller1.navigationItem.title = [NSString stringWithFormat:@"%@",@(0)];
[self.viewcontroller.navigationController pushViewController: controller1 animated:YES];
// UIViewController *viewcontroller = [[UIViewController alloc]init];
// [viewcontroller pushViewController:controller1 animated:YES];
}
自己理解, [self.viewcontroller.navigationController pushViewController: controller1 animated:YES];
应该是可以调用,但是既没有报错,也没有反应,郁闷中