您好我有自定义视图在didSelectAnnotationView当用户点击制造商我显示与UILabel和UIButton自定义视图一切都工作正常,但UIButton不可点击请告诉如何解决这个问题。UIButton无法正常工作didSelectAnnotationView
我的代码。
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view1
{
NSString *bult;
if ([view1.annotation isKindOfClass:[MapPin class]]) {
MapPin *annot = view1.annotation;
NSLog(@"tit%@",annot.nsname);
bult=annot.nsname;
}
myview = [[UIView alloc]initWithFrame:CGRectMake(-60, -110, 200, 100)];
myview.layer.cornerRadius = 10;
myview.backgroundColor = [UIColor yellowColor];
myview.userInteractionEnabled = YES;
[view1 addSubview:test];
buldingname = [[UILabel alloc] initWithFrame:CGRectMake(5, -15, 150, 80)];
buldingname.text=bult;
[buldingname setTextColor:[UIColor blackColor]];
[buldingname setBackgroundColor:[UIColor clearColor]];
[buldingname setFont:[UIFont fontWithName: @"Trebuchet MS" size: 14.0f]];
buldingname.lineBreakMode = NSLineBreakByWordWrapping;
buldingname.numberOfLines = 3;
[myview addSubview:buldingname];
moredetail=[UIButton buttonWithType:UIButtonTypeRoundedRect];
moredetail.frame= CGRectMake(0, 55, 200, 50);
[moredetail setTitle:@"Click here for more details" forState:UIControlStateNormal];
[moredetail addTarget:self action:@selector(nextbtn:) forControlEvents:UIControlEventTouchUpInside];
[moredetail setExclusiveTouch:YES];
[myview addSubview:moredetail];
}
我的调用方法。
- (IBAction)nextbtn:(id)sender
{
NSLog(@"click");
}
我已经使用上面的代码,它不工作,请告诉我在哪里做错了如何解决这个问题。
在此先感谢。
我改变了它仍然不能正常工作 – Shanthanu 2015-04-01 06:50:01
什么是测试? – 2015-04-01 07:11:07