ios - 没有获得按钮操作/单击自定义 MKannotation 调用 View
<p><p>我为我的 mapView 创建了自定义注释和标注。当用户单击标注 View 或单击添加为标注 View 的 subview 的按钮时,我需要导航到另一个 View 。但是在这种情况下,手势识别器和添加目标都不适合我。 setSelected: 方法被调用,当在调用 View 中点击时 View 被隐藏。</p>
<pre><code> @interface VBPunchCardAnnotation : MKAnnotationView{
UIView *calloutView;
}
- (id)initWithAnnotation:(id )annotation reuseIdentifier:(NSString *)reuseIdentifier deal:(id)punchdeal
{
self = ;
calloutView = [ init];
calloutView.hidden = YES;
infoButton = ;
;
UITapGestureRecognizer *singleTap = [ initWithTarget:self action:@selector(annotationTapped:)];
singleTap.numberOfTapsRequired = 1;
singleTap.delegate = self;
;
;
;
return self;
}
-(void)setSelected:(BOOL)selected animated:(BOOL)animated
{
// show/hide callout and swap pin image
calloutView.hidden = !selected;
self.image = !selected ? normalPin : selectedPin;
// dispatch an event to alert app a pin has been selected
if(selected) [ postNotificationName:@"punchCardAnnotation" object:self];
}
-(void)annotationTapped:(id)sender{
;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><pre><code>- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event
{
UIView* hitView = ;
if (]) {
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 没有获得按钮操作/单击自定义 MKannotation 调用 View ,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/21986501/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/21986501/
</a>
</p>
页:
[1]