菜鸟教程小白 发表于 2022-12-11 18:14:33

ios - 是否可以在objc中的ios中播放小于0.25秒的振动


                                            <p><p>我需要在ios中播放振动小于0.25秒,振动的顺序是这样的</p>

<p>1 次振动 0.25 秒,然后 3 次振动 0.15 秒,此循环将持续有限的时间,例如 2 或 3 分钟。这里还需要准确性意味着每次振动都必须在准确的时间开始</p>

<p>现在当我播放振动时,它每秒播放一次</p>

<pre><code>-(IBAction)onBtnVibrateClicked:(id)sender {
    ;

    ;
    if(_txt_VibrationPerMinute.text.length == 0){
      _txt_VibrationPerMinute.text = @&#34;10&#34;;
    }
    myTimer =
                                     target:self
                                 selector:@selector(targetMethod:)
                                 userInfo:nil
                                    repeats:YES];
}

- (IBAction)obBtnStopVibrationClicked:(id)sender {

    ;


}

-(void)targetMethod:(NSTimer *)timer {
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>是的,你可以使用这样的东西</p>

<pre><code>FOUNDATION_EXTERN void AudioServicesPlaySystemSoundWithVibration(UInt32 inSystemSoundID,id arg,NSDictionary* vibratePattern);

void vibrate(float durationInSeconds, float intensivity, long count)
{
    NSMutableDictionary* dict = ;
    NSMutableArray* arr = ;
    for (long i = count; i--;)
    {
      ]; //vibrate
      ];

      ];//stop
      ];
    }

    ;
    forKey:@&#34;Intensity&#34;];

    AudioServicesPlaySystemSoundWithVibration(4095,nil,dict);
}
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 是否可以在objc中的ios中播放小于0.25秒的振动,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/40930556/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/40930556/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 是否可以在objc中的ios中播放小于0.25秒的振动