星空网 > 软件开发 > 操作系统

【代码笔记】调用系统震动和声音

代码:

RootViewController.m

【代码笔记】调用系统震动和声音images/loading.gif' data-original="http://common.cnblogs.com/images/copycode.gif" />
#import "RootViewController.h"#import <AudioToolbox/AudioToolbox.h>@interface RootViewController ()@end@implementation RootViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];  if (self) {    // Custom initialization  }  return self;}- (void)viewDidLoad{  [super viewDidLoad];  // Do any additional setup after loading the view.    self.title=@"RootViewController";    //这个震动不震动,有没有声音是和手机的设置一样的。    //调用系统震动  [self getChatMessageGoToShake];  //调用系统声音  [self getChatMessageGoToSound];}#pragma -mark -调用系统震动- (void)getChatMessageGoToShake{   //调用系统震动   AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);}#pragma -mark -调用系统声音- (void)getChatMessageGoToSound{  //调用系统声音  NSString *path = [NSString stringWithFormat:@"/System/Library/Audio/UISounds/%@.%@",@"sms-received3",@"caf"];  if (path) {    SystemSoundID sd;    OSStatus error = AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path],&sd);    //获取声音的时候出现错误    if (error != kAudioServicesNoError) {      NSLog(@"----调用系统声音出错----");      sd = 0;    }    AudioServicesPlaySystemSound(sd);  }}- (void)didReceiveMemoryWarning{  [super didReceiveMemoryWarning];  // Dispose of any resources that can be recreated.}
【代码笔记】调用系统震动和声音

 

 


 

原标题:【代码笔记】调用系统震动和声音

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

跨境电商客服:https://www.goluckyvip.com/tag/13976.html
中东电商优势:https://www.goluckyvip.com/tag/13977.html
外贸趋势:https://www.goluckyvip.com/tag/13978.html
跨境电商2022:https://www.goluckyvip.com/tag/13979.html
脱颖而出:https://www.goluckyvip.com/tag/1398.html
墨西哥西红柿:https://www.goluckyvip.com/tag/13980.html
健康成新热词!给你马来西亚GMV增长加速器 :https://www.goluckyvip.com/news/218216.html
健康成新热词!给你马来西亚GMV增长加速器 :https://www.xlkjsw.com/news/91226.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流