두 개의 ViewController로 새 프로젝트를 만들고 LTC 대신 오른쪽에서 왼쪽으로 ViewController
을 푸시하는 클래스를 가져 왔지만이를 사용할 수는 없습니다. UIRightToLeft.m 내부의 pushViewController
이 호출되지 않고 그 이유를 알 수 없습니다. 내 목표는 RTL 언어로 작업하도록하는 것입니다.간단한 메서드를 재정의 할 수 없습니다.
#import "UIRightToLeft.h"
@implementation UIRightToLeft
- (id)initWithRootViewController:(UIViewController *)rootViewController
{
self = [super initWithRootViewController:rootViewController];
if (!self)
return nil;
return self;
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
NSLog(@"pushViewController");
// Add the viewController and a fake controller without animation. Then pop the fake controller with animation.
UIViewController *fakeController = [[UIViewController alloc] init] ;
[super setViewControllers:[[self viewControllers] arrayByAddingObjectsFromArray:[NSArray arrayWithObjects:viewController, fakeController, nil]] animated:NO];
[super popViewControllerAnimated:animated];
}
- (void)popViewControllerAnimatedStep2:(UIViewController *)viewController
{
// Push the new top controller with animation
[super pushViewController:viewController animated:YES];
// Remove the view that should have been popped
NSMutableArray *arr = [NSMutableArray arrayWithArray:[self viewControllers]];
[arr removeObjectAtIndex:[[self viewControllers] count]-2];
[super setViewControllers:[NSArray arrayWithArray:arr] animated:NO];
}
- (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
NSLog(@"popViewControllerAnimated");
if (animated)
{
// Save the controller that should be on top after this pop operation
UIViewController *newTopController = [[self viewControllers] objectAtIndex:[[self viewControllers] count]-2];
// Remove it from the stack. Leave the view that should be popped on top
NSMutableArray *arr = [NSMutableArray arrayWithArray:[self viewControllers]];
[arr removeObjectAtIndex:[[self viewControllers] count]-2];
[super setViewControllers:[NSArray arrayWithArray:arr] animated:NO];
// Schedule the next step
[self performSelector:@selector(popViewControllerAnimatedStep2:) withObject:newTopController afterDelay:0];
return [arr objectAtIndex:[arr count]-1];
}
return [super popViewControllerAnimated:NO];
}
@end
ViewController.m :
#import "ViewController.h"
#import "UIRightToLeft.h"
#import "SecondViewController.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.
}
- (IBAction)pressMe:(UIButton *)sender {
SecondViewController *next = [[SecondViewController alloc]init];
[self.navigationController pushViewController:next animated:YES];
}
@end
ViewController.h :
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
- (IBAction)pressMe:(UIButton *)sender;
@end
(푸시와 두 번째 ViewController
에 draged 단 하나 개의 버튼을 거기에 내 ViewController
에서)
정확히 달성하려는 것은 무엇입니까? 일반 푸시 애니메이션은 이미 오른쪽에서 왼쪽입니다. 왼쪽에서 오른쪽으로의 의미가 있습니까? ViewController.m의 self.navigationController가 UIRightToLeft 클래스 또는 UINavigation 컨트롤러를 가리 킵니까? – rdelmar
나는 사과가 제공하는 다른 방법으로 viewcontroller 사이를 이동하려고합니다. (RTL 언어 용). 'self.navigationController'가 어디를 가리키고 있는지 모르겠습니다. 이것은 내가 가지고있는 모든 코드입니다 – Segev
그럼 self.navigationController (pressMe 메서드에서)를 로깅 한 다음 반환되는 내용을 확인하십시오. – rdelmar