我将我的子类UINavigationController
化为使用 UIRTLNavigationController.m 从右到左执行推送(非正常行为)我已在此问题的底部添加并收到以下警告:
nested push animation can result in corrupted navigation bar
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
我研究了这些错误并发现了一个阻止您接收它们的类:https ://github.com/Plasma/BufferedNavigationController
我已将 BufferedNavigationController .h 和 .m 添加到我的项目中,将 BufferedNavigationController.h 中的行更改为:@interface BufferedNavigationController : UIRTLNavigationController 并将 BufferedNavigationController 设置为我UINavigationController
在 IB 中的自定义子类。
视图仍在从右向左移动,在 BufferedNavigationController 内部调用了方法,但我仍然收到有关嵌套的警告,并且 ..Navigation Bar 子视图树可能已损坏..
任何帮助,将不胜感激。
UIRTLNavigationController.m:
#import "UIRTLNavigationController.h"
@implementation UIRTLNavigationController
- (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] autorelease];
[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];
}
- (void)dealloc {
[super dealloc];
}
@end