ios 实现摇一摇并震动
来源:互联网 发布:java 服务端开发 编辑:程序博客网 时间:2024/06/06 14:15
iphone 手机实现摇一摇并震动,代码网上都有
使用时需要注意:
1、添加AudioToolbox.framework
2、导入头文件
#import <AudioToolbox/AudioServices.h>
代码如下:
- (void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after loading the view from its nib. [[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES]; [self becomeFirstResponder]; }
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{ //检测到摇动 NSLog(@"开始摇动了"); }- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{ //摇动结束 if (event.subtype == UIEventSubtypeMotionShake) { //something happens [self test]; }else{ NSLog(@"好怪异啊"); } }- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event{ //摇动取消 NSLog(@"取消摇动了");}- (BOOL)canBecomeFirstResponder { return YES; }#import <AudioToolbox/AudioServices.h>-(void)test{ NSLog(@"完成摇动后处理事件"); AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); }
0 0
- ios 实现摇一摇并震动
- iOS编程 摇一摇 震动
- ios 设置摇一摇震动
- iOS view中震动类似实现
- 实现ios提示音播放与震动
- 实现ios提示音播放与震动
- IOS-震动
- ios 震动
- iOS 震动
- ios 震动
- Unity 摇一摇震动并随机播放音乐
- iOS实现手机的连续震动和停止震动的代码(拷如工程就能用)
- untiy实现手机摇一摇震动效果
- Unity3D 手机摇一摇 实现震动效果
- IOS简单的实现手机震动的提示
- iOS CAShapeLayer + UIBezierPath 实现震动条调效果
- IOS震动调用
- IOS静音还是震动
- String类__【String类的应用】
- RIGHT JOIN
- founding
- 8张图理解Java
- 应用系统数据缓存设计
- ios 实现摇一摇并震动
- 珊瑚SDK的一些开发建议!
- 第2次实验——算法基本功 与 综合思考
- JBoss与IIS服务器集成(转载)
- 万年历(实用系统,非ACM题目)
- Android.mk 实用的实例
- Oracle PL-SQL中 左连接和右连接用法
- FULL JOIN
- java中的一些编程题目