杀死View并返回rootViewController

Aja*_*anz 2 iphone uitabbarcontroller ios

我是IOS的新手,如果我问一个愚蠢的问题,请提前抱歉.

我使用UITabBarController和navigationController来控制视图.

在我的最后一个视图中,我想在按下按钮时有一个按钮,视图将返回到我通过MainWindow.xib文件设置的rootViewController并杀死在app后台运行的任何进程.

在我想回到rootViewController之前,这是我在上一个视图中的代码:

-(IBAction)doneButtonPressed:(id)sender{


    JourneyIndexViewController *journeyIndexVC = [[JourneyIndexViewController alloc]     initWithNibName:@"JourneyIndexViewController" bundle:nil];

    [journeyIndexVC setDistanceLabelValue:self.distanceLabelValue];

    [self.navigationController pushViewController:journeyIndexVC animated:YES];
    [journeyIndexVC release];
    [self dismissModalViewControllerAnimated:YES];

    }
Run Code Online (Sandbox Code Playgroud)

JourneyIndexViewController是我在MainWindow.xib中设置的rootViewController.

非常感谢您的支持.

Fra*_*ade 7

尝试

[self.navigationController popToRootViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)

你应该看看这个:UINavigationController类参考,以便更好地理解