나는 솔루션 형제가 있습니다. 나는 당신의 질문에 샘플 프로젝트를 시도했습니다. 이제 해결책을 얻었습니다.
먼저 storyboard.SeeUnavigationController, ViewController, LeftViewController, RightViewController가있는 스토리 보드에서 ViewController를 아래 스크린 샷으로 설정하십시오. RightViewController.m
#import "ViewController.h"
#import "RightViewController.h"
#import "LeftViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//swipe right
UISwipeGestureRecognizer *gestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeHandlerRight:)];
[gestureRecognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[self.view addGestureRecognizer:gestureRecognizer];
//swipe left
UISwipeGestureRecognizer *gestureRecognizer2 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeHandlerLeft:)];
[gestureRecognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[self.view addGestureRecognizer:gestureRecognizer2];
}
#pragma mark - swipe right function
-(void)swipeHandlerRight:(id)sender
{
RightViewController *videoScreen=[self.storyboard instantiateViewControllerWithIdentifier:@"RightViewController"];
CATransition *animationRight = [CATransition animation];
[animationRight setDuration:0];
[animationRight setType:kCATransitionFromRight];
[animationRight setSubtype:kCATransitionFromRight];
[animationRight setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[self.view.window.layer addAnimation:animationRight forKey:kCATransition];
[self presentViewController:videoScreen animated:NO completion:nil];
}
#pragma mark - swipe left function
-(void)swipeHandlerLeft:(id)sender
{
LeftViewController *videoScreen=[self.storyboard instantiateViewControllerWithIdentifier:@"LeftViewController"];
CATransition *animationLeft = [CATransition animation];
[animationLeft setDuration:0];
[animationLeft setType:kCATransitionFromLeft];
[animationLeft setSubtype:kCATransitionFromLeft];
[animationLeft setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[self.view.window.layer addAnimation:animationLeft forKey:kCATransition];
[self presentViewController:videoScreen animated:NO completion:nil];
}
ViewController.m
에
그런 다음
#import "RightViewController.h"
@interface RightViewController()
@end
@implementation RightViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Back to MiddleView
- (IBAction)actionBackToMiddleView:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
LeftViewController.m 당신이 무엇을 달성하고자하는
#import "LeftViewController.h"
@interface LeftViewController()
@end
@implementation LeftViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Back to MiddleView
- (IBAction)actionBackToMiddleViewFromLeftView:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
, 난 당신이해야한다고 생각 페이지 뷰 컨트롤러를 사용하거나 페이징이 활성화 된 상태에서 스크롤 뷰에 3 개의 뷰를 넣으십시오. 귀하의 요구 사항에 따라 원하는만큼 큰 scrollview 너비를 확인하십시오. –
그 방법은 한 번도 호출하지 않습니까? – Nilesh
@ NileshJha 중단 점을 추가하고 프로그램을 실행하면 뷰가 호출 될 것입니다. 왼쪽으로 스 와이프하면 중단 점이 leftViewController로 이동하지만 오른쪽으로는 여전히 중간 레이블이 표시됩니다. 왼쪽 레이블이 표시되어야합니다. 각 화면에 레이블을 추가 할 때 왼쪽으로 스 와이프합니다. – virat