当从当前页面(回退到首页可能中间有好多个页面)回退到首页,大多做法是直接push到首页,这样会加重内存负担。
此处建议用下面的方法pop到首页去(因为页面的堆栈中已经有首页了,直接pop出去就可以了)。(此处的首页是ViewController.m来,包含ViewController.h就可以了)
for (UIViewController *tempin self.navigationController.viewControllers)
{
if ([tempisKindOfClass:[ViewControllerclass]])
{
[self.navigationControllerpopToViewController:temp animated:YES];
}
}