gpt4 book ai didi

ios - 未获得按钮操作/单击自定义 MKannotation 调出 View

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:36:16 27 4
gpt4 key购买 nike

我已经为我的 map View 创建了自定义注释和标注。当用户单击调出 View 或者他单击作为 subview 添加到调出 View 的按钮时,我需要导航到另一个 View 。但在这种情况下,手势识别器和添加目标都不适合我。调用 setSelected: 方法,当点击发生在调用 View 中时 View 被隐藏。

 @interface VBPunchCardAnnotation : MKAnnotationView{

UIView *calloutView;
}

- (id)initWithAnnotation:(id )annotation reuseIdentifier:(NSString *)reuseIdentifier deal:(id)punchdeal
{
self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
calloutView = [[UIView alloc] init];
calloutView.hidden = YES;

infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];

[calloutView addSubview:infoButton];

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(annotationTapped:)];
singleTap.numberOfTapsRequired = 1;
singleTap.delegate = self;
[calloutView addGestureRecognizer:singleTap];

[infoButton addTarget:self action:@selector(annotationTapped:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:calloutView];

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) [[NSNotificationCenter defaultCenter] postNotificationName:@"punchCardAnnotation" object:self];
}

-(void)annotationTapped:(id)sender{
[self.delegate punchCardAnnotationClickedForDeal:self.punchDeal];
}

最佳答案

- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event
{
UIView* hitView = [super hitTest:point withEvent:event];
if ([hitView isKindOfClass:[UIButton class]]) {

}
}

关于ios - 未获得按钮操作/单击自定义 MKannotation 调出 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21986501/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com