iPhoneでシェイクイベントを取得できません。
私はここで他の質問に従いましたが、結果はありません。AppleのGLPaintの例にも従おうとしましたが、ソースコードとまったく同じように見えますが、わずかな違いがあります。GLPaintのソースコード/works/、私の/ doesn't/。
だから、ここに私が持っているものがあります:
Controller.m
- (void)awakeFromNib {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shakeEnded) name:@"shake" object:nil];
}
ShakingEnabledWindow.m
- (void)shakeEnded {
NSLog(@"Shaking ended.");
}
- (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:@"shake" object:self];
NSLog(@"Shaken!");
}
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event {
}
私のXIBには、ShakingEnabledWindowであるウィンドウとオブジェクトである私のコントローラーがあります。
私はここでアイデアが不足しています。誰かが私に手を貸してくれることを願っています。:)