有一些無證 「私人的事情」:
UIDevice.currentDevice().valueForKey("_feedbackSupportLevel");
它回報2與觸覺反饋設備 - iPhone 6/6 +讓您可以輕鬆地使用它來產生觸覺反饋:
let generator = UIImpactFeedbackGenerator(style: .heavy)
generator.prepare()
generator.impactOccurred()
返回1爲iPhone 6S,這裏是產生taptic回退:
import AudioToolbox
AudioServicesPlaySystemSound(1519) // Actuate `Peek` feedback (weak boom)
AudioServicesPlaySystemSound(1520) // Actuate `Pop` feedback (strong boom)
AudioServicesPlaySystemSound(1521) // Actuate `Nope` feedback (series of three weak booms)
和返回0爲iPhone 6或舊設備。由於它是一種無證件的東西,它可能會阻止你在審查階段,雖然我能夠通過審查和提交應用程序與這樣的檢查。
更多細節: http://www.mikitamanko.com/blog/2017/01/29/haptic-feedback-with-uifeedbackgenerator/
如果你想退回到使用舊AudioServicesPlaySystemSound如果taptic引擎不可用? –
@DanielLarsson這可能會對您有所幫助。你想在版本10之前檢查iOS。http://nshipster.com/swift-system-version-checking/ – Adrian
@Adrian剛剛測試過iOS 9,看起來它只是不做任何事情(不崩潰的應用程序)。 – Idan