本文介绍了popTOViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为"HOME"的按钮.在该按钮操作中,我有以下代码:
I have a button named 'HOME'. In that button action I have the following code:
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
当我单击此按钮时,我的应用程序崩溃.
When I click this button my app crashes.
将索引从1更改为2,然后可以完美地弹出视图.
Changing the index from 1 to 2, then it pops the view perfectly.
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES];
我的查看顺序是Page1-> Page2-> Page3
My view sequence is Page1 --> Page2 --> Page3
我想从Page3转到Page1,但是该应用程序崩溃了.从Page3到Page2都可以正常工作.
I want to go from Page3 to Page1 but the app crashes. From Page3 to Page2 it works fine.
推荐答案
尝试一下.
在我编写SeeMyScoresViewController的地方,应该编写必须去的View Controller类.(例如Home类)
Where I have written SeeMyScoresViewController you should write your View Controller class on which you have to go.(eg. Class of Home)
NSArray *viewControllers = [[self navigationController] viewControllers];
for( int i=0;i<[viewControllers count];i++){
id obj=[viewControllers objectAtIndex:i];
if([obj isKindOfClass:[SeeMyScoresViewController class]]){
[[self navigationController] popToViewController:obj animated:YES];
return;
}
}
这篇关于popTOViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!