您的位置:首页 > 移动开发 > IOS开发

iOS 摇一摇的实现-备用

2016-02-24 23:37 459 查看
- (void)viewDidLoad

{

[super viewDidLoad];

[[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];

[self becomeFirstResponder];

}

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

//检测到摇动

}

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

//摇动结束

if (event.subtype == UIEventSubtypeMotionShake) {

//something happens

[self test];

}

}

- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

//摇动取消

}

- (BOOL)canBecomeFirstResponder {

return YES;

}

-(void)test

{

NSLog(@"完成摇动后处理事件");

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: