0

UITapGestureRecognizerUIImageView内部で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);
    // ...
}

ここで何が間違っていますか?サンクス!!!

4

0 に答える 0