Reputation: 2077
I have this inside my viewcontroller.m
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (event.type == UIEventSubtypeMotionShake) {
NSLog(@"shake shake shake");
}
}
- (void)viewDidLoad
{
[self performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.3];
}
But when I shake my phone nothing happens. Why?
Upvotes: 0
Views: 227
Reputation: 3152
I had the same problem and I'm not sure what is the reason for it. However, I have a solution.. When I call [self becomeFirstResponder] in the viewDidAppear method, the shake detection works.
- (void) viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
I hope this helps.
Upvotes: 1