iOS 摇一摇功能

来源:互联网 发布:visio mac版下载 编辑:程序博客网 时间:2024/06/10 03:41
摇一摇是借助手机的传感器功能,实现监控

// motion是移动的意思,end结束的意思,motion的参数,也就运动的类型,event传递UI的事件。
(void)motionEnded: (UIEventSubtype)motion withEvent:(UIEvent *)event
{
    if (motion  == UIEventSubtypeMotionShake) {
        NSLog(@“检测到摇一摇”);
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@“Hello world”  message:@“摇一摇” delegate:nil  cancelButtonTitle:@“OK” otherButtonTitle:nil]; // 创建对话框并初始化
        [alertView show];

    }
}
0 0