我在使用导航堆栈推送视图时遇到了一些问题.
我遇到的问题是,在触摸标签栏项后,视图控制器被推入导航堆栈(来自名为FirstViewController的视图控制器),如下所示:
- (void)viewDidLoad
{
[super viewDidLoad];
svc = [[SecondViewController alloc] init];
[self.navigationController pushViewController:svc animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
这可以按预期工作,但是当再次触摸相同的标签栏项时会出现实际问题.
当发生这种情况时,当前视图(之前推送的SecondViewController)被删除,就像我将触摸"完成"按钮一样.
我无法追踪发生的地点或原因.
编辑:这是我设置标签栏,查看控制器和导航的方式:
@implementation AppDelegate
@synthesize HomeViewController, FirstViewController, SecondViewController, ThirdViewController, SettingsViewController, tabBarController, window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
FirstViewController *firstViewController = [[FirstViewController alloc]
initWithNibName:nil bundle:nil];
UINavigationController *firstViewControllerNav = [[UINavigationController alloc]
initWithRootViewController:firstViewController];
SecondViewController *secondViewController = [[SecondViewController alloc]
initWithNibName:nil bundle:nil];
UINavigationController *secondViewControllerNav = [[UINavigationController alloc]
initWithRootViewController:secondViewController];
ThirdViewController *thirdViewController = [[ThirdViewController alloc]
initWithNibName:nil bundle:nil];
UINavigationController *thirdViewControllerNav = …Run Code Online (Sandbox Code Playgroud)