显示UIAlertView时播放本地通知默认声音? [英] Play local notification default sound when displaying UIAlertView?

查看:146
本文介绍了显示UIAlertView时播放本地通知默认声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在撰写iPhone的提醒应用程式,使用本机通知显示提醒。

I'm writing a reminders app for iPhone that displays reminders using local notifications.

如果在应用程式执行时提醒已关闭, t显示。相反,在我的应用程序委托中调用 didReceiveLocalNotification 方法,我通过显示一个 UIAlertView 模拟本地通知对话框

If a reminder goes off while the application is running, the local notification isn't displayed. Instead, the didReceiveLocalNotification method is called in my app delegate, and I mimic the local notification dialog by displaying a UIAlertView with the reminder text.

当本地通知显示在应用程序外部时,设备会振动,声音由 UILocalNotificationDefaultSoundName 。再次,我想在应用程序中显示 UIAlertView 时模仿这一点。

When local notifications are displayed outside of the app, the device vibrates and the sound specified by UILocalNotificationDefaultSoundName is played. Again, I'd like to mimic this in the app when displaying the UIAlertView.

我可以振动设备通过调用 AudioServicesPlaySystemSound(kSystemSoundID_Vibrate),但我不知道如何播放本地通知默认声音。没有等效的SystemSoundID常数,我不确定路径是什么。

I can vibrate the device by calling AudioServicesPlaySystemSound(kSystemSoundID_Vibrate), but I can't figure out how to play the local notification default sound. There's no equivalent SystemSoundID constant, and I'm not sure what the path would be.

tl; dr 显示UIAlertView时本地通知默认声音。任何想法?

tl;dr I'd like to play the local notification default sound when displaying a UIAlertView. Any ideas?

推荐答案

好问题。理想情况下,会有一种使用AudioServices选择系统声音的方法。但是,以下来自Apple的System Sound Services Reference的声明建议:

Good question. Ideally, there would be a way of selecting a system sound using AudioServices. However, the following statement from Apple's "System Sound Services Reference" suggests otherwise:


在Mac OS X中,当用户有
将系统首选项配置为闪烁
屏幕的警报,或者如果声音
无法呈现,调用此
函数将导致屏幕
闪烁。在Mac OS X中,将
常数
kSystemSoundID_UserPreferredAlert传递给
,以播放由系统首选项中的
用户选择的警报声音。 在iOS
中没有优先用户提醒
音效。

似乎SDK没有什么提供,你可能希望通过使用自己的wav文件模仿系统的声音。有一个很好的图书馆在以下链接,也许它会有你正在寻找的声音: http://sites.google.com/site/iphonesounds/iPhoneOriginalSystemSounds_WAV.zip

Since it seems like the SDK has little to offer, you might wish to mimick the system sounds by using your own wav file. There is a nice library at the following link, perhaps it will have the sound you're looking for: http://sites.google.com/site/iphonesounds/iPhoneOriginalSystemSounds_WAV.zip

祝你好运!

这篇关于显示UIAlertView时播放本地通知默认声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆