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???
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
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.