摇一摇是借助手机的传感器功能,实现监控
// 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];
}
}
// 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];
}
}