- (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
This comment has been removed by the author.
ReplyDeleteNice1
ReplyDeletevery halpful
thank you very much bro.
what is "IsCenter"?
ReplyDeleteIsCenter is boolean. that is check that current view is in center or not.
DeleteDo you have the tutorial for this?It will be helpful to me
DeleteCan you please explain me what you want. So I will give you the solution or tutorial.
Delete