我正在尝试测量iPhone,iOS 6上的默认振动持续时间:
@property (nonatomic, retain) NSDate *startDate;
- (void) runTest
{
AudioServicesAddSystemSoundCompletion(kSystemSoundID_Vibrate, NULL, NULL, playSoundFinished, self);
self.startDate = [NSDate date];
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
}
void playSoundFinished(SystemSoundID soundID, void *data)
{
MyClassName *foo = (MyClassName*)data;
double vibrationDurationMs = [foo.startDate timeIntervalSinceNow] * -1000.0;
}
但无论是否在系统设置中激活振动,它都只返回1-2毫秒。
我听说默认持续时间应为400毫秒,然后是100毫秒的静音。
以上代码是否正确?