Domanda

I have this cose in my app:

- (void) touch:(UIPanGestureRecognizer*)gesture{
if (gesture.state == UIGestureRecognizerStateBegan) 
    {   
        if (gesture.numberOfTouches == 1) 
        {
            // some code
        }
        else if (gesture.numberOfTouches == 2) //some code
        else return;
}
else if (gesture.state == UIGestureRecognizerStateChanged)
{
    if (gesture.numberOfTouches == 1){

        // some code            
     }
    else if (gesture.numberOfTouches == 2) // some code 

    else return;
}

else if (gesture.state == UIGestureRecognizerStateEnded     ||
         gesture.state == UIGestureRecognizerStateCancelled ||
         gesture.state == UIGestureRecognizerStateFailed)
{   
    // some code
}

}

it work fine in ios 5 but not in ios 4.3...why???

È stato utile?

Soluzione

Here is a code to add a Pan Gesture for a View.Like that for which control you have added a recognizer in your code?

- (void)viewDidload:(BOOL)animated{
    UIRotationGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(touch:];
    [self.view addGestureRecognizer:panRecognizer];
[super viewDidLoad:animated];
}

- (void) touch:(UIPanGestureRecognizer*)gesture{
if (gesture.state == UIGestureRecognizerStateBegan) 
    {   
        if (gesture.numberOfTouches == 1) 
        {
            // some code
        }
        else if (gesture.numberOfTouches == 2) //some code
        else return;
}
else if (gesture.state == UIGestureRecognizerStateChanged)
{
    if (gesture.numberOfTouches == 1){

        // some code            
     }
    else if (gesture.numberOfTouches == 2) // some code 

    else return;
}

else if (gesture.state == UIGestureRecognizerStateEnded     ||
         gesture.state == UIGestureRecognizerStateCancelled ||
         gesture.state == UIGestureRecognizerStateFailed)
{   
    // some code
}
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top