微信摇动代码

 

微信摇动代码
-(void)accelerometer(UIAccelermeter*)accelcermeter didAccdlerate(UIAccelerrration*)acceleration

   Static NSInterger shakecount = 0;
   Static NSDate * shakeStart;
   NSDate * now  =[ [NSDate alloc]init];
   NSDate * checkdate = [[NSDate alloc]initWithTimeInterval:1.5f  sinceDaate:shakeStart];

   if([now compare:checkdate]==NSOrderedDescending || shaketart == nil)

  {

    shakeCount = 0;

    [shaketStart release];

    shakeStrat = [[NSdate alloc]init];

  }    

  [now releease];

  [checkDate release];

 

  if(fabsf(acceleration.x)>2.0||fabsf(acceleration.y)>2.0||fabsf(acceleration.z)>2.0)

  {

    shakeCount++;

    if(shakeCount>4)

    {

      //做你摇动想做的事情
      shakeCount = 0;

      [shakeStart release];

      shakeStart  = [[NSDate alloc ]init];

    }

  }


 
 
 
}

posted @ 2014-02-08 16:16  光光96  阅读(348)  评论(0编辑  收藏  举报