简体   繁体   English

当我在iPhone的导航栏上单击时,如何弹出所需的视图控制器

[英]How can i pop to a required view controller when i click on back on navigation bar in iPhone

In my application i have 6 different view controllers. 在我的应用程序中,我有6个不同的视图控制器。 1. Home page 2. A table view 3. Details of table view elements, this is also a table view with 4 rows 4. 4,5,6 Edit / modification views of details (each row in details table can modified and reloaded) 1.主页2.一个表格视图3.表格视图元素的详细信息,这也是一个具有4行的表格视图4. 4,5,6详细信息的编辑/修改视图(详细信息表中的每一行都可以修改和重新加载)

When edit hte data of details view in 4,5,6 views the navigation is pushed to 2nd view details view. 在4,5,6视图中编辑详细信息视图的数据时,导航将推至第二视图详细信息视图。

when ever i clicked on back navigation in details it pop to the previous view which is modified recently. 每当我单击详细的后退导航时,它将弹出到最近修改的上一个视图。 But i need to pop (pushed to left/back side but not pushed to right side )to the tableview1 so i created a leftnavigation item implemented action for this button. 但是我需要弹出(推到左侧/背面,但不推到右侧)到tableview1,所以我为此按钮创建了一个实现了leftnavigation项目的动作。

UIBarButtonItem *backButton = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(backclick:)] autorelease];
    self.navigationItem.leftBarButtonItem = backButton;

In click acitio I used three different approaches 在click acitio中,我使用了三种不同的方法

1.popToRootViewcontroller : it takes back to the home page. so ,didn't need it (X)
2.[self.navigationController pushViewController:abc animated:YES]; it pushes right/front (X)
3.present model view controller

all are working and takes to the table view but not in the correct direction ie not pop to the back just pusshes to front. 所有这些都可以正常工作,并进入表格视图,但方向不正确,即没有弹出到后面,而只是往前推。 so, I used popto viewcontoller. 因此,我使用了popto viewcontoller。

4.popViewController (it is the correct process i guess) but it crashes and shows an error view soesnot exixst 4.popViewController(我猜这是正确的过程),但它崩溃并显示错误视图soesnot exixst

-(IBAction)backclick:(id)sender
{
    ChronologyViewController *temp = [[ChronologyViewController alloc]initWithNibName:@"ChronologyViewController" bundle:nil];
        [self.navigationController popToViewController:temp animated:YES];
}
for (UIViewController *vc in [self.navigationController viewControllers]) {
    if ([vc isMemberOfClass:[yourViewController class]]) {
        NSLog(@"Inside if");
        [self.navigationController popToViewController:vc animated:YES];
        return;
    }
}

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

相关问题 导航栏后退按钮弹出视图 Controller - Navigation Bar Back Button Pop View Controller 我如何模仿iPhone日视图导航栏 - How can I mimic the iphone day view navigation bar 导航栏在iPhone sdk中的弹出视图控制器上隐藏 - Navigation bar gets hide on pop view controller in iPhone sdk 如何一次弹出模态视图和上一个导航控制器视图? - How can I pop a modal view and the previous navigation controller view at once? 选择选项卡栏时,iPhone弹出导航控制器 - iPhone pop navigation controller when tab bar selected 像Instagram iPhone应用程序一样向右滑动导航弹出视图。我如何实现这一目标? - Navigation pop view when swipe right like Instagram iPhone app.How i achieve this? iPhone:当用户按下已选择的选项卡时,如何使UINavViewController不弹出视图控制器 - iPhone: How do I get the the UINavViewController to not pop the view controller when the user presses the tab that is already selected iPhone:如何覆盖导航控制器中的后退按钮? - iPhone: How do I override the back button in a Navigation Controller? 当我导航回到主视图时,导航栏可见 - navigation bar is visible when i navigate back to main view 当我返回到iOS中的视图时隐藏导航栏 - navigation bar is hidden when i return back to view in iOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM