【发布时间】:2009-10-10 12:23:37
【问题描述】:
我有一个 ViewController 可以完美地与触发动作的按钮配合使用。我想用一个震动事件替换按钮,所以我用谷歌搜索它并创建了一个继承自 UIView 的 ShakeDetector 类
我的实现如下:
@implementation ShakeDetector
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (motion == UIEventSubtypeMotionShake )
{
// User was shaking the device. Post a notification named "shake".
//[[NSNotificationCenter defaultCenter] postNotificationName:@"spin" object:self];
NSLog(@"sss");
}
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
}
@end
但我不能让它工作......有什么帮助吗?
谢谢
【问题讨论】:
标签: iphone events triggers detection shake