可能重复:
为手电筒应用程序激活 LED
如何在 iPhone 上的摇动手势上产生 LED 灯,以下是我正在使用的代码,但我无法在 iphone 的摇动手势上获得 LED 灯,我浏览了一些 pdf 和一些文件,但我无法获得正确的解决方案。
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (event.type == UIEventTypeMotion && event.subtype == UIEventSubtypeMotionShake)
{
UIAlertView * shakeAns = [[UIAlertView alloc]
initWithTitle:@"Hey..."
message:@"Shake Gesture!"
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil];
[shakeAns show];
[shakeAns release];
self.view.backgroundColor = [UIColor whiteColor];
}
}
由于我能够更改背景颜色和警报,因此我需要在摇动手势上显示 LED 灯。
提前致谢。