在iOS应用程序的本地通知中实施振动和声音设置
我有一个名为“通知音”的标签。在它的点击手势上,我想打开一个iOS设备的默认提示音列表。选择任何一种警报音时,所选警报音应设置为“我的本地通知音”。如何实现这一点 另外,我想为本地通知添加振动开/关设置。我成功地检查了振动开关是否打开/关闭。当开关打开时,我使用以下代码设置振动。在iPhone上进行了测试,但没有成功。你知道如何实施吗 声音和振动是否共同作用于本地通知在iOS应用程序的本地通知中实施振动和声音设置,ios,objective-c,uilocalnotification,audio,vibration,Ios,Objective C,Uilocalnotification,Audio,Vibration,我有一个名为“通知音”的标签。在它的点击手势上,我想打开一个iOS设备的默认提示音列表。选择任何一种警报音时,所选警报音应设置为“我的本地通知音”。如何实现这一点 另外,我想为本地通知添加振动开/关设置。我成功地检查了振动开关是否打开/关闭。当开关打开时,我使用以下代码设置振动。在iPhone上进行了测试,但没有成功。你知道如何实施吗 声音和振动是否共同作用于本地通知 if([[UIDevice currentDevice].model isEqualToString:@"iPhone"]) {
if([[UIDevice currentDevice].model isEqualToString:@"iPhone"])
{
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
}
else
{
// Not an iPhone, so doesn't have vibrate
// play the less annoying tick noise or one of your own
AudioServicesPlayAlertSound (kSystemSoundID_Vibrate);
}
如果这仍然适用于iOS 7.1及以下版本,那么您可以使用UIActionSheet轻松做到这一点 但是,如果您想根据对该项的选择执行操作,我建议使用UIButton,例如:(注意:这是用于在代码中执行的) 这基本上会让你走上正轨。我不相信编程是正确的,除非你自己学习。所以,到这里来看看苹果的文档
- (void) actionMethod
{
UIActionSheet *action = [[UIActionSheet alloc]...];
// set action delegate
// the delegate method is where you want to check
// what option you want to do and all the other stuff
}
- (void) viewDidLoad
{
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
b.frame = ...;
[b setTitle:@"Notification Sound" ...];
[b addTarget:self selector:@selector(actionMethod) ...];
[self.view addSubview:b];
}