- (void)viewDidLoad
{
[super viewDidLoad];
appDel = (AppDelegate*)[[UIApplication sharedApplication]delegate];
appDel.IsCenter = TRUE;
firstView = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
UISwipeGestureRecognizer *leftSwipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(leftSwipe:)];
[leftSwipe setDirection:(UISwipeGestureRecognizerDirectionUp)];
leftSwipe.delegate = self;
[self.view addGestureRecognizer:leftSwipe];
[leftSwipe release];
UISwipeGestureRecognizer *rightSwipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(rightSwipe:)];
[rightSwipe setDirection:(UISwipeGestureRecognizerDirectionDown)];
rightSwipe.delegate = self;
[self.view addGestureRecognizer:rightSwipe];
[rightSwipe release];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)leftSwipe:(UISwipeGestureRecognizer *)recognizer
{
if (appDel.IsCenter == TRUE) {
CATransition *transition = [CATransition animation];
transition.duration = 0.75;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromTop;
transition.delegate = self;
[self.view.layer addAnimation:transition forKey:nil];
[self.view addSubview:firstView.view];
appDel.IsCenter = FALSE;
}
else {
[secondView.view removeFromSuperview];
appDel.IsCenter = TRUE;
}
}
- (void)rightSwipe:(UISwipeGestureRecognizer *)recognizer
{
if (appDel.IsCenter == TRUE) {
CATransition *transition = [CATransition animation];
transition.duration = 0.75;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromBottom;
transition.delegate = self;
[self.view.layer addAnimation:transition forKey:nil];
[self.view addSubview:secondView.view];
appDel.IsCenter = FALSE;
}
else {
[firstView.view removeFromSuperview];
appDel.IsCenter = TRUE;
}
}
My Facebook
{
[super viewDidLoad];
appDel = (AppDelegate*)[[UIApplication sharedApplication]delegate];
appDel.IsCenter = TRUE;
firstView = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
UISwipeGestureRecognizer *leftSwipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(leftSwipe:)];
[leftSwipe setDirection:(UISwipeGestureRecognizerDirectionUp)];
leftSwipe.delegate = self;
[self.view addGestureRecognizer:leftSwipe];
[leftSwipe release];
UISwipeGestureRecognizer *rightSwipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(rightSwipe:)];
[rightSwipe setDirection:(UISwipeGestureRecognizerDirectionDown)];
rightSwipe.delegate = self;
[self.view addGestureRecognizer:rightSwipe];
[rightSwipe release];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)leftSwipe:(UISwipeGestureRecognizer *)recognizer
{
if (appDel.IsCenter == TRUE) {
CATransition *transition = [CATransition animation];
transition.duration = 0.75;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromTop;
transition.delegate = self;
[self.view.layer addAnimation:transition forKey:nil];
[self.view addSubview:firstView.view];
appDel.IsCenter = FALSE;
}
else {
[secondView.view removeFromSuperview];
appDel.IsCenter = TRUE;
}
}
- (void)rightSwipe:(UISwipeGestureRecognizer *)recognizer
{
if (appDel.IsCenter == TRUE) {
CATransition *transition = [CATransition animation];
transition.duration = 0.75;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromBottom;
transition.delegate = self;
[self.view.layer addAnimation:transition forKey:nil];
[self.view addSubview:secondView.view];
appDel.IsCenter = FALSE;
}
else {
[firstView.view removeFromSuperview];
appDel.IsCenter = TRUE;
}
}
My Facebook