我在我的应用中有这个代码:
- (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
}
}
它在ios 5中工作正常但在ios 4.3中没有...为什么???
答案 0 :(得分:0)
这是一个为View添加Pan Gesture的代码。就像你在代码中为哪个控件添加了识别器一样?
- (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
}
}