大佬教程收集整理的这篇文章主要介绍了如何回到Objective-C中的上一个视图?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用这段代码:
-(IBACtion)onclickhome:(id)sender { [self.navigationController popViewControllerAnimated:YES]; }
我在主页按钮点击事件中使用了navigationController,但它没有跳转到主屏幕.
你是什么意思
?
如果要弹出到根控制器,可以使用popToRootViewControllerAnimated.
[self.navigationController popToRootViewControllerAnimated:YES];
来自Apple的UINavigationController文档
popToRootViewControllerAnimated: Pops all the view controllers on the stack except the root view controller and updates the display. - (NSArray *)popToRootViewControllerAnimated:(BOOL)animated
如果您已经设置了UINavigationController并且其根控制器被称为A,那么如果您从A导航到B然后从B导航到C,那么您有两种可能性来回到之前的控制器(您可以使用其他控制器但我列出了主控制器)那些):
>使用popViewControllerAnimated从C导航回B.>使用popToRootViewControllerAnimated从C导航回A
以上是大佬教程为你收集整理的如何回到Objective-C中的上一个视图?全部内容,希望文章能够帮你解决如何回到Objective-C中的上一个视图?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。