[英]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.