ios - How to disable UIButton vibration -


up until today have been testing apps in simulator. first time tested project on real iphone. unpleasantly surprised every time press button phone vibrates. wouldn't big deal except particular app has built in keyboard plays audio sound every time key (uibutton) pressed.

enter image description here

the combination of vibration sound plus audio sound distracting. is there way programmatically disable button vibration? i'm not asking how disable vibration phone, buttons choose. relevant question find opposite: making iphone vibrate.

i don't have leave user turn vibration off in settings, i?

update 1:

judging comments, maybe either device specific problem or somehow triggering vibration.

this how play sound:

import foundation import audiotoolbox  class player {      private let audiofolder = "raw"      func playsoundfromfile(file: string) {         var soundurl: nsurl?         var soundid: systemsoundid = 0         let filepath = nsbundle.mainbundle().pathforresource("\(audiofolder)/\(file)", oftype: "mp3")         soundurl = nsurl(fileurlwithpath: filepath!)         if let url = soundurl {             audioservicescreatesystemsoundid(url, &soundid)             audioservicesplayalertsound(soundid)         }     } } 

and button tap action:

@ibaction func keytapped(sender: uibutton) {      let buttontext = sender.titlelabel?.text ?? ""      updatedisplayforipa(buttontext)      // play sound     if let filename = singlesound.filenameforipa(buttontext) { // converts ipa sound symbol filename          player.playsoundfromfile(filename)     }  } 

since tap calls update display method, here is:

func updatedisplayforipa(ipa: string) {      if let filename = singlesound.filenameforipa(ipa) {          ipalabel.text = ipa // uilabel         ipadescription.text = "\(filename)_description".localized // uitextview         ipadescription.scrollrangetovisible(nsrange(location: 0, length: 0))         example1.settitle("\(filename)_example1".localized, forstate: uicontrolstate.normal) // uibutton         example2.settitle("\(filename)_example2".localized, forstate: uicontrolstate.normal) // uibutton         example3.settitle("\(filename)_example3".localized, forstate: uicontrolstate.normal) // uibutton      } } 

i don't see here trigger vibration...

update 2

i created new project , added single uibutton storyboard. tested on same phone vibrates in above app. there no vibration when tapped button, there must above code triggering vibration. be?

audioservicesplayalertsound can cause vibration:

iphone—plays specified sound. if user has configured settings application vibration on ring, invokes vibration.

i'd try audioservicesplaysystemsound instead:

to play short sound not used alert, use audioservicesplaysystemsound.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -