IOS:UIPanGesture 不适用于 ios 4.3

Posted

技术标签:

【中文标题】IOS:UIPanGesture 不适用于 ios 4.3【英文标题】:IOS: UIPanGesture don't work on ios 4.3 【发布时间】:2012-03-27 14:39:37 【问题描述】:

我的应用中有这个角色:

- (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 中却不行...为什么???

【问题讨论】:

你为哪个控件添加了这个手势?你能在你创建这个手势的地方发布代码吗? 【参考方案1】:

这是为视图添加平移手势的代码。就像您在代码中为哪个控件添加了识别器一样?

- (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


【讨论】:

以上是关于IOS:UIPanGesture 不适用于 ios 4.3的主要内容,如果未能解决你的问题,请参考以下文章

SpriteKit 中的 UIPanGesture

CAGradientLayer 不适用于 iOS 7(但适用于 iOS 6)

CollectionView EstimatedItemSize 不适用于 iOS 9 和 10

iOS 13 modalPresentationStyle = UIModalPresentationFullScreen 不适用于 MFMessageComposeViewController

UIScrollView 和 UINavigationController 不适用于 iOS 4

sqPaymentForm 不适用于 IOS 自动填充