iOS摇一摇功能方法实现

来源:互联网 发布:教学过程最优化 编辑:程序博客网 时间:2024/06/10 01:43
//只需要让这个Controller本身支持摇动 //同时让他成为第一相应者: - (void)viewDidLoad {    [super viewDidLoad];     [[UIApplicationsharedApplication] setApplicationSupportsShakeToEdit:YES];     [selfbecomeFirstResponder];}    //然后去实现那几个方法 - (void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {     //检测到摇动 }    - (void) motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event {     //摇动取消 }    - (void) motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {     //摇动结束     if (event.subtype == UIEventSubtypeMotionShake) {         //something happens     } }
0 0
原创粉丝点击