iOS 8中的自定义振动 - Swift [英] Custom vibration in iOS 8 - Swift

查看:575
本文介绍了iOS 8中的自定义振动 - Swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在swift编写一个基于精灵工具包的应用程序,需要使用振动进行简短的触觉反馈

I'm writing a sprite kit-based app in swift and need to make a short haptic feedback using vibration

所以首先我导入了AudioToolbox并使用了这个

so first I imported AudioToolbox and used this

AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))

它运作良好,但它振动太久,无法控制这个持续时间。

and it worked well but it vibrates for too long and there's no way to control this duration.

然后经过一番搜索,我读了Kevin Cao的在这里回答:

Then after some searching I read Kevin Cao's answer here:

iOS中是否有用于自定义振动的API?

但遗憾的是AudioServicesPlaySystemSoundWithVibration专用功能仅在iOS 6中可用。

but unfortunately AudioServicesPlaySystemSoundWithVibration private function was only usable in iOS 6.

那么还有其他可能的方法吗?

so is there any other possible way?

推荐答案

您需要AudioServicesPlaySystemSoundWithVibration API。
但不幸的是,它是私密的,你无法发布你的应用程序:(

You need AudioServicesPlaySystemSoundWithVibration API. But unfortunately it's private and you can not publish your app :(

检查这篇博客文章这个答案

这篇关于iOS 8中的自定义振动 - Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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