2

次のメソッドが実装されたカスタムscrollViewがあります。

  - (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
 {
     //if not dragging send it on up the chain
     if(!self.dragging){
    [self.nextResponder touchesEnded:touches withEvent:event];
     }else {
        [super touchesEnded:touches withEvent:event];

     }
  }

そして、My View Controllerには、次の方法があります。

-(void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {


NSLog(@"TOUCH");
//---get all touches on the screen---

NSSet *allTouches = [event allTouches];



//---compare the number of touches on the screen---

switch ([allTouches count])

{

        //---single touch---

    case 1: {

        //---get info of the touch---

        UITouch *touch = [[allTouches allObjects] objectAtIndex:0];



        //---compare the touches---

        switch ([touch tapCount])

        {

                //---single tap---

            case 1: {
                NSLog(@"Single");

                [self mySingleTapMethod];
            } break;



                //---double tap---

            case 2: {

                [self myDoubleTapMethod];
            } break;

        }

    }  break;

}

}

iOS 4では、これは完全に機能し、scrollviewのタッチが認識され、touchesEndedがビューコントローラーで呼び出され、すべてが正しく機能します。ただし、iOS 5xでは、touchesEndedが起動されることはありません。一体何が起こっているのか/間違っているのか誰かが知っていますか?

4

1 に答える 1

3

ここで答えを見つけました。基本的に、私が行っていることを実行したい場合は、touchesBeginをチェーンの上位に渡す必要があります。viewControllerがtouchesBeganを認識しなかった場合、TouchesEndedを取得しないためです。カスタムScrollViewを変更してtouchesBeganをスローし、5.0ですべてが正常に機能するようになりました

参照:

UIViewのタッチ処理動作はXcode4.2で変更されましたか?

于 2012-07-07T18:22:27.097 に答える