The following code I have for a shake gesture works perfectly fine, it just when I have it across three separate uitableviews and once you leave one tableview to go to the next one, the shake gesture no longer works. Any idea how to make it work across all three viewcontrollers? Plus I have the option to tweet out information on the "detailviewcontroller" however, once you leave one of the table views it disables the keyboard for twitter. Any ideas to how to fix this? Thanks!
//BEGIN SHAKE GESTURE CODE
- (void)viewDidAppear:(BOOL)animated {
[self becomeFirstResponder];
}
- (void)viewDidDisappear:(BOOL)animated {
[self resignFirstResponder];
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (event.subtype == UIEventSubtypeMotionShake) {
int section = 0;
int row = arc4random() %36;
NSIndexPath * path = [NSIndexPath indexPathForRow:row inSection:section];
[self handleSelectedRow:path.row];
[self.tableView selectRowAtIndexPath:path animated:YES scrollPosition: UITableViewScrollPositionNone];
}
}
-(void)handleSelectedRow:(int)row;
{
UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.tag = row;
[self performSegueWithIdentifier:@"showRecipeDetail" sender:btn];
}
//END SHAKE GESTURE CODE