检测手机的震动需要导入
创新互联建站是一家专注于网站设计制作、做网站与策划设计,上栗网站建设哪家好?创新互联建站做网站,专注于网站建设十多年,网设计领域的专业建站公司;建站业务涵盖:上栗等地区。上栗做网站价格咨询:18980820575
然后实现下面方法即可
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{
if (motion == UIEventSubtypeMotionShake) {
NSLog(@"手机开始摇动");
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);//让手机震动
}
}
在模拟器中运行时,可以通过
[Hardware]-[Shake Gesture]
(或者command+shift+z)
来测试[摇一摇]功能
1、打开摇一摇功能
[UIApplication sharedApplication].applicationSupportsShakeToEdit =YES;
2、让需要摇动的控制器成为第一响应者
[selfbecomeFirstResponder];
3、实现以下方法
// 开始摇动
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent*)event
// 取消摇动
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
// 摇动结束
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
当前题目:ios开发摇一摇,ios 摇一摇
网站网址:https://www.cdcxhl.com/article16/dsisigg.html
成都网站建设公司_创新互联,为您提供网站内链、品牌网站制作、外贸建站、虚拟主机、网站设计、Google
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联