我無法在iPhone上獲得搖動事件。無法在iPhone上獲得搖動事件
我在這裏跟着其他問題沒有結果。我也嘗試過遵循Apple的GLPaint示例,但它看起來與我的源代碼完全相同,只是有一點不同。 GLPaint的源代碼/ works /,mine /不會/。
所以,這裏是我:
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 {
}
我的廈門國際銀行有一個窗口,這是一個ShakingEnabledWindow和對象,我的控制器。
我在這裏想法不多,希望有人能幫我一把。 :)
你是否試圖讓它與'View'或'ViewController'一起工作? – FreeAsInBeer 2011-04-03 22:16:15
在窗口中,如下所示:http://developer.apple.com/library/ios/#samplecode/GLPaint/Introduction/Intro.html – MegaEduX 2011-04-03 22:16:56