UINavigationController
提供的常用接口是push和pop,但都是操作最顶层的页面topViewController
,若要操作指定的页面,可以访问属性viewControllers
@implementation UINavigationController(zlAddition)
- (void)zl_popTheViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if (viewController.navigationController == self)
{
if (self.topViewController == viewController)
{
[self popViewControllerAnimated:animated];
}
else
{
NSMutableArray *arr = [self.viewControllers mutableCopy];
if (arr.lastObject != viewController)
{
[arr removeObject:viewController];
[self setViewControllers:arr animated:animated];
}
}
}
}
@end
发表回复
要发表评论,您必须先登录。