ios摇一摇

-(void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

    if (motion==UIEventSubtypeMotionShake)

        NSLog(@"Shake begin");

}

-(void) motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

    if (motion==UIEventSubtypeMotionShake)

        NSLog(@"Shaked");

}

-(void) motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

    if (motion==UIEventSubtypeMotionShake)

        NSLog(@"Shake cancel");

}

原文地址:https://www.cnblogs.com/punkrocker/p/4454109.html