As per the above comments discussed i am answering my question so that others can read the solution that i have got
In the UIResponder class documentation it is said that the motion events will respond to the first responder only so what i did was add just a small function and that did the trick for me, so here's my solution
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if(event.type == UIEventSubtypeMotionShake)
{
NSLog(@"called");
[self.view setBackgroundColor:[UIColor greenColor]];
}
}
- (BOOL)canBecomeFirstResponder
{
return YES;
}
Now still i was not able to detect any shake motion so all i had to do was to make my viewcontroller the first responder and for that here's the code that i used
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
and i was done
This was the solution that i came up with
Thanks and Regards
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…