模拟器也支持摇一摇功能 [Hardware]-[Shake Gesture]或者command+shift+z来测试
代码非常简单,直接在ViewController添加代码
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"开始摇一摇");
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"摇一摇被取消");
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"摇一摇停止");
}