iOS 摇一摇功能

2016-05-17  本文已影响199人  Mnnni

模拟器也支持摇一摇功能 [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(@"摇一摇停止");
}
上一篇下一篇

猜你喜欢

热点阅读