I got the answer after breaking head for a day!!! (maybe a piece of cake for others).
here goes the solution:
In the root view controller or view controller from where we present modal view controller we have to detect shake:
- (void) viewWillAppear:(BOOL)animated
{
[self becomeFirstResponder];
[super viewWillAppear:animated];
}
- (void) viewWillDisappear:(BOOL)animated
{
//[self resignFirstResponder];
/*dont resign first responder on view disappear */
[super viewWillDisappear:animated];
}
- (BOOL)canBecomeFirstResponder
{
return YES;
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if ( event.subtype == UIEventSubtypeMotionShake )
{
// Put in code here to handle shake
}
if ( [super respondsToSelector:@selector(motionEnded:withEvent:)] )
[super motionEnded:motion withEvent:event];
}
present the modal view normally... shake will be detected in modalview also...
Its tested and working!!
Thanks all :)