- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch=[touches anyObject];
touchBeganPoint = [touch locationInView:[[UIApplication sharedApplication] keyWindow]];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:[[UIApplication sharedApplication] keyWindow]];
CGFloat xOffSet = touchPoint.x - touchBeganPoint.x;
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if (xOffSet < 0) {
[appDelegate makeRightViewVisible];
}
else if (xOffSet > 0) {
[appDelegate makeLeftViewVisible];
}
self.navigationController.view.frame = CGRectMake(xOffSet,
self.navigationController.view.frame.origin.y,
self.navigationController.view.frame.size.width,
self.navigationController.view.frame.size.height);
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
// animate to left side
if (self.navigationController.view.frame.origin.x < -kTriggerOffSet)
[self moveToLeftSide];
// animate to right side
else if (self.navigationController.view.frame.origin.x > kTriggerOffSet)
[self moveToRightSide];
// reset
else
[self restoreViewLocation];
}