私は揺れイベントをしようとしています。 私は試しました: 1)How do I detect when someone shakes an iPhone?(ケンドールとエランの投稿) 2)motionBegan: Not Working しかしnothigが役立ちます。 私のビューは最初のレスポンダーになりますが、motionBegan/motionEndedは決して呼び出されません。 いくつかのadditiol設定が必要ですか、またはsomethigがありませんか?私のiOS SDKは4.3です。モーションコールバックは一度も呼び出されません
私はUIViewのクラスがあります。ビューの私のViewControllerのXIBクラスで
#import "ShakeView.h"
@implementation ShakeView
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
NSLog (@"123");
if (event.subtype == UIEventSubtypeMotionShake) {
NSLog(@"Shake!");
}
if ([super respondsToSelector:@selector(motionEnded:withEvent:)]) {
[super motionEnded:motion withEvent:event];
}
}
@end
はShakeViewです。
- (void) viewDidAppear:(BOOL)animated
{
[self.view becomeFirstResponder];
[super viewWillAppear:animated];
NSLog(@"%d", [self.view isFirstResponder]);
}
- (void) viewWillDisappear:(BOOL)animated
{
[self.view resignFirstResponder];
[super viewWillDisappear:animated];
}
それが記録されます "1"、それはファーストレスポンダIS:私のViewControllerで
Wheel *secondViewController = [[Wheel alloc] initWithNibName:@"Wheel" bundle:nil];
[self.navigationController pushViewController:secondViewController animated:YES];
[secondViewController release];
を: 私のViewControllerを押します。しかし、それは何も記録しない。
私はコードのこの数行で半日を過ごすため、私はもうアイデアはありません。誰もそれを解決する方法を知っていますか?おかげさまで