UINavigationController子类在iOS7上的作用不同,并从self.viewController中删除viewController

UINavigationController子类在iOS7上的作用不同,并从self.viewController中删除viewController,ios,objective-c,uinavigationcontroller,ios7,Ios,Objective C,Uinavigationcontroller,Ios7,在我的一个应用程序中,我使用了一个子类UINavigationController,以便将ViewControllers从右向左推,而不是通常的从左向右推。我正在使用下一个代码来替换pop和push动画来实现这一点。它在低于iOS 7的所有iOS上都运行良好 以下是我代码的相关部分: UINavigationController子类: - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)anim

在我的一个应用程序中,我使用了一个子类
UINavigationController
,以便将
ViewControllers
从右向左推,而不是通常的从左向右推。我正在使用下一个代码来替换pop和push动画来实现这一点。它在低于iOS 7的所有iOS上都运行良好

以下是我代码的相关部分:

UINavigationController子类:

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    // 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];
    NSLog(@"Log1: %d",[self.viewControllers count]);
    [super popViewControllerAnimated:animated];
    NSLog(@"Log2: %d",[self.viewControllers count]);
    [self performSelector:@selector(test) withObject:Nil afterDelay:5];
}

-(void)test
{
      NSLog(@"Log3: %d",[self.viewControllers count]);
}
Log1:3
Log2:2
Log3:2
Log1:3
Log2:2
Log3:1 //<---This is my problem
在iOS 6上,日志将显示:

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    // 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];
    NSLog(@"Log1: %d",[self.viewControllers count]);
    [super popViewControllerAnimated:animated];
    NSLog(@"Log2: %d",[self.viewControllers count]);
    [self performSelector:@selector(test) withObject:Nil afterDelay:5];
}

-(void)test
{
      NSLog(@"Log3: %d",[self.viewControllers count]);
}
Log1:3
Log2:2
Log3:2
Log1:3
Log2:2
Log3:1 //<---This is my problem
在iOS 7上,日志将显示:

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    // 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];
    NSLog(@"Log1: %d",[self.viewControllers count]);
    [super popViewControllerAnimated:animated];
    NSLog(@"Log2: %d",[self.viewControllers count]);
    [self performSelector:@selector(test) withObject:Nil afterDelay:5];
}

-(void)test
{
      NSLog(@"Log3: %d",[self.viewControllers count]);
}
Log1:3
Log2:2
Log3:2
Log1:3
Log2:2
Log3:1 //<---This is my problem
Log1:3
日志2:2

Log3:1//推送
viewController
fakeViewController
而不是直接设置如何。推送viewController将在iOS 7:Log1:3 Log2:2 Log3:1上得到相同的结果