简体   繁体   English

弹出不足以删除视图控制器

[英]Popping not sufficient to remove a view controller

I am experiencing an issue and I believe it's due to me incorrectly removing my view. 我遇到了一个问题,我认为这是由于我错误地删除了我的观点。 I will try to explain and hope all can follow. 我将尽力解释并希望所有人都能跟随。 I have a UISplitview app which essentially has two views. 我有一个UISplitview应用程序,它基本上有两个视图。 The main detail view, and a view which is essentially a map. 主要详细视图,以及实质上是地图的视图。 Upon selecting a certain string in the table this code is called (this code is in the detailview but the rainObject is passed in from a UIViewController . 在表中选择某个字符串后,将调用此代码(此代码在detailview中,但是rainObject是从UIViewController传递的。

-(void)setReceivedRainObject:(id)receivedRainObject{
    if ([receivedRainObject isEqualToString:@"Test"]){
        mapViewController *mapView=[[mapViewController alloc]initWithNibName:@"mapViewController" bundle:nil location:0];
        [self.navigationItem setHidesBackButton:NO animated:NO];
        [self.navigationController setNavigationBarHidden:NO animated:YES];
        [self.navigationController pushViewController:mapView animated:NO];
    }
}

So the above code loads my map fine in the detailscreen as expected. 因此,以上代码按预期将我的地图加载到了详细屏幕中。 However, when I click the first option (test) from the left view controller, it calls a new view controller (viewcontroller2 with a row named test2) and that second controller calls a third( viewcontroller3 with a row named test3) On the viewDidDisappear of viewcontoller3 and in the viewWillAppear of test I have this code 然而,当我点击左侧视图控制器的第一个选项(测试),它会调用一个新的视图控制器(viewcontroller2与行名为test2的),而第二控制器调用第三(与命名TEST3排viewcontroller3)在viewDidDisappear的viewcontoller3和在测试的viewWillAppear ,我有此代码

 [self.detailViewController.navigationController popViewControllerAnimated:NO];

So when I drill down to viewcontroller, when I click the backbutton, it pops off one map, and when testview loads it pops the second. 因此,当我向下浏览到viewcontroller时,当我单击后退按钮时,它将弹出一个地图,而当testview加载时,它将弹出第二个地图。 leaving my detail view showing exactly how I started. 保留我的详细视图,以准确显示我的开始方式。 However, I've noticed that if I clicked the "test" button twice, and try to go back, there is an "extra screen" that was supposed to be remove with pop. 但是,我注意到,如果我单击两次“测试”按钮,然后尝试返回,则应该弹出一个“额外的屏幕”。 Would like to know how to remove this mass of views or to stop the program from adding so many. 想知道如何删除大量视图或停止添加太多视图。 Thanks 谢谢

Just use 只需使用

mapViewController *mapView=[[mapViewController alloc]initWithNibName:@"mapViewController" bundle:nil location:0];
[self.navigationController pushViewController:mapView animated:YES];

to navigate through the view controllers. 在视图控制器中导航。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM