简体   繁体   English

iOS-导航控制器后退按钮

[英]iOS - navigation controller back button

I'm developing an iPad App using storyboards. 我正在使用情节提要开发一个iPad App。 In this app when the user click on "preferences" appear a modal View. 在此应用中,当用户单击“首选项”时,将出现一个模式视图。 One button of this view send the user to another View Controller (but this view has an action bar to go back to his root view controller), but when user taps the action bar back button nothing happen (it's called navigationController popViewControllerAnimated), the user continue in the same view. 该视图的一个按钮将用户发送到另一视图控制器(但是此视图具有一个可返回其根视图控制器的操作栏),但是当用户点击操作栏的后退按钮时,什么也没有发生(称为navigationController popViewControllerAnimated),该用户继续以相同的观点。

Can anyone help me?? 谁能帮我??

Thanks. 谢谢。

UPDATE: 更新:

The code to handle the back button: 处理后退按钮的代码:

- (IBAction)btnBackTapped:(id)sender {
   [self.navigationController popViewControllerAnimated:YES];
}

I'm using Segue (from storyboard) to call this View Controller: 我正在使用Segue(从情节提要中)来调用此View Controller:

When the user click on "Meus Favoritos" 当用户单击“ Meus Favoritos”时

在此处输入图片说明

They will be redirect to this page: 他们将被重定向到此页面:

在此处输入图片说明

The segue is with a Modal (from image one to two)... segue带有模态(从图一到二)...

When you are presenting a View Controller modally, it is likely not within a Navigation Controller, so probably the reference to navigationController in your code is nil , can you check that? 模态显示View Controller时,它可能不在Navigation Controller中,因此代码中对navigationController的引用可能是nil ,您可以检查一下吗?

If you are presenting your View Controller modally this will work instead 如果您以模态展示View Controller,它将代替

[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];

However, if you actually want to use a Navigation Controller, you should embed the View Controller that is presenting the Preferences View Controller in a Navigation Controller and present the Preferences View Controller with a show segue instead of a modal one. 但是,如果您实际上要使用导航控制器,则应将显示“首选项”视图控制器的“视图控制器”嵌入“导航控制器”中,并向“首选项”视图控制器show segue”而不是“ modal

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

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