

我遇到的问题是:我点击按钮,但是CalloutView似乎收到了我的点击而不是UIButton。
首先要解释一下:1. "SYSUMyAnnoCalloutView“是MKPinAnnotationView 2. "SYSUMyCalloutImageView”是UIImageView,我在"SYSUMyAnnoCalloutView“一书中给它加上了addSubview 3. UIButton和UILabel在"SYSUMyCalloutImageView”中是addSubviewed
对应代码: 1.在"SYSUMyAnnoCalloutView.m“中
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
if (selected){
[self.calloutImageView setFrame:CGRectMake(-75, -100, 230, 130)];
[self animateCalloutAppearance];
//[self.calloutImageView becomeFirstResponder];
//[self.calloutImageView.detailButton addTarget:self.calloutImageView action:@selector(clickForDetail) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:self.calloutImageView];
[self setCanShowCallout:NO];
}
else
{
//Remove your custom view...
[self.calloutImageView removeFromSuperview];
}
}有人能解决我的问题吗?将非常感谢:)
发布于 2012-12-18 05:45:08
默认情况下,UIImageView不接受用户交互。
您应该尝试在SYSUMyCalloutImageView.m的initWithImage中添加这一行代码
[self setUserInteractionEnabled:YES];https://stackoverflow.com/questions/13926864
复制相似问题