我UITapGestureRecognizer
在UIImageView
里面UIView
只能识别图像一小部分的点击。我使用以下代码:
// definig inside @interface call inside .h
UITapGestureRecognizer* languageSelector;
// initializing inside initWithFrame
UIImage* langSelPopImg = [UIImage imageNamed:@"lang_EN_pop.png"];
langPopView = [[UIImageView alloc] initWithImage:langSelPopImg];
CGRect positioningHelper = CGRectMake(0, langSelPopImg.size.height, langSelImg.size.width, langSelImg.size.height);
langSelActiveLanguageView.frame = positioningHelper;
self.repositioningY = langSelPopImg.size.height;
self.bounds = CGRectMake(0, 0, langSelImg.size.width, langSelImg.size.height + langSelPopImg.size.height);
self.clipsToBounds = YES;
// setting it up from inside an animateWithDuration/completion call:
languageSelector = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(languageSelectorTapped:)];
[langPopView addGestureRecognizer:languageSelector];
langPopView.userInteractionEnabled = YES;
// the method that only detects taps betwen y = 69 and y = 93
-(void)languageSelectorTapped:(UITapGestureRecognizer *)sender
{
CGPoint location = [languageSelector locationInView:languageSelector.view];
CGPoint touchPoint = [(UITapGestureRecognizer*)sender locationInView:langPopView];
NSLog(@"x:%f/y:%f", touchPoint.x, touchPoint.y);
// ...
}
我在这里做错了什么?谢谢!!!