微信摇动代码

微信摇动代码
-(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];

    }

  }


 
 
 
}

微信摇动代码

上一篇:【微信公众平台开发】php开发环境搭建设置(一)


下一篇:手动裁剪制作小linux系统