我希望我的所有 View 都是可点击的,而不仅仅是 leftCalloutAccessoryView
或 r ightCalloutAccessoryView
,我也希望中心也可以点击
最佳答案
您可以使用,
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:calloutView];
BOOL isPointInsideView = [calloutView pointInside:touchPoint withEvent:nil];
if (isPointInsideView)
{
// place your action code.
}
}
或者你可以使用,
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapCalloutAction:)];
tapGestureRecognizer.delegate = self;
tapGestureRecognizer.numberOfTapsRequired = 1;
[calloutView addGestureRecognizer:tapGestureRecognizer];
-(void) tapCalloutAction:(id)sender
{
// do stuff
}
关于ios - 标注注释 View 不可点击中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19446823/