Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That's true that before 3.2 UISwipeGestureRecognizer is compiled without warning or errors as stated before but however, I experienced a problem about that. My app was compiled but when I run my app in a 3.1 iphone, UISwipeGestureRecognizer was detecting a swipe event twice. So, I made some conditional coding. My implementation:</p> <pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { float version = [[[UIDevice currentDevice] systemVersion] floatValue]; if (version &lt; 3.2) { UITouch *touch = [touches anyObject]; startPosition = [touch locationInView:self]; } [super touchesBegan:touches withEvent:event]; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { float version = [[[UIDevice currentDevice] systemVersion] floatValue]; if (version &lt; 3.2){ UITouch *touch = [touches anyObject]; CGPoint endPosition = [touch locationInView:self]; if (endPosition.x-startPosition.x&gt;30) { //difference between end and start must be min. 30 pixels to be considered as a swipe. if you change it as startPosition.x-endPosition.x you could detect left swipe [self handleSwipe]; //my swipe handler } } [super touchesEnded:touches withEvent:event]; } </code></pre> <p>and in another method, let's say in viewdidload</p> <pre><code>float version = [[[UIDevice currentDevice] systemVersion] floatValue]; if (version &gt;= 3.2){ UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe)]; [self addGestureRecognizer:swipe]; } </code></pre> <p>This implementation saves you from the risk of using a private api, although it is not private now. Also, it eliminates the duplicate swipe event problem.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload