iPhone SDK - 线程触发振动
我目前正在开发一个 iPhone 应用程序,如果发生特殊事件,它应该使手机振动。
触发警报的检查是在线程中完成的。
拨打电话,手机不会振动
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
不幸的是,如果我从线程内部 。 (如果我在“viewDidAppear”方法中调用它,效果很好)。
我什至尝试从 thead 内部进行回调,如下所示:
inside Thread:
[self performSelectorOnMainThread:@selector(doAlarm)
withObject:nil
waitUntilDone:true];
-(void)doAlarm {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
其结果相同:手机没有振动。
如何使手机从线程内部振动?
提前致谢
I'm currently working on an IPhone App that should make the phone vibrate if a special event occurs.
The checks to trigger the alert is done in a thread.
Unfortunately the phone won't vibrate if I call
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
from inside the thread. (It works fine if I call this in my "viewDidAppear" method).
I even tried to do a callback from inside the thead like this:
inside Thread:
[self performSelectorOnMainThread:@selector(doAlarm)
withObject:nil
waitUntilDone:true];
-(void)doAlarm {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
which has the same result: No vibration on the phone.
How do I make the phone vibrate from inside a thread ??
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
知道了 !
有一个麦克风侦听器处于活动状态,导致了该问题。
Got it !
There were a Microphone Listener active which caused the problem.