rickytan / RTRootNavigationController

Implicitly make every view controller has its own navigation bar
MIT License
2.15k stars 379 forks source link

当前viewController使用`self.navigationItem.title = @"首页";`设置标题后, push新的控制器, 返回按钮与系统自带的不一样 #168

Closed voisen closed 6 years ago

voisen commented 6 years ago

当前viewController使用self.navigationItem.title = @"首页";设置标题后, push新的控制器, 返回按钮与系统自带的不一样, push出来的控制器的返回title一律为Back而不是前一个控制器的标题

voisen commented 6 years ago
- (void)pushViewController:(UIViewController *)viewController
                  animated:(BOOL)animated
{
    if (self.viewControllers.count > 0) {
        UIViewController *currentLast = RTSafeUnwrapViewController(self.viewControllers.lastObject);
        [super pushViewController:RTSafeWrapViewController(viewController,
                                                           viewController.rt_navigationBarClass,
                                                           self.useSystemBackBarButtonItem,
                                                           currentLast.navigationItem.backBarButtonItem,
                                                           currentLast.navigationItem.title)
                         animated:animated];
    }
    else {
        [super pushViewController:RTSafeWrapViewController(viewController, viewController.rt_navigationBarClass)
                         animated:animated];
    }
}

已解决: 上面的改动是currentLast.title改为currentLast.navigationItem.title

rickytan commented 6 years ago

你用 self.title = @"首页" 就好了