實現搖一搖, 在iOS中有2種方式1. 利用加速計的值, 來判斷是否搖動了2. 利用系統封裝好的motionBegan,如今基本都在使用此方式spa
//相似touchBegan3d
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)eventorm
{it
NSLog(@"開始搖一搖");io
}event
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)eventmargin
{touch
NSLog(@"搖完了");top
}ant
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"搖動取消");
}