问题描述
我有一个应用程序,其中有一个表格视图.当按下单元格上的一个按钮时,我必须转到另一个视图控制器(即:testviewcontroller),以显示我在上一个中选择的内容.然后在按下一个按钮时我需要转到另一个显示剩余值的视图控制器.如果他在那里选择一个,那么我需要重复上述过程.问题是从这里我也将一些值带到该testviewcontroller.if我跳回到我的视图控制器我该如何携带新值.目前我正在这样做.
I have an application in which i am having a table view.when pressing a button on the cell i have to go to another view controller(ie:testviewcontroller) showing what i selected in the previous one.then when pressing one button i need to go to another view controller showing the remaing values.if he select one there then i need to repeat the above process.The problem is from here also i am carrying some values to that testviewcontroller.if i pop back to my view controller how can i carry the new values.currently i am doing like this.
TestViewController *test =[[ TestViewController alloc]initWithNibName:@"TestViewController" bundle:nil];
test.itemselected=head;
test.itemid=productid;
//NSLog(@"%@",del.navigationController);
[del.navigationController pushViewController:test animated:YES];
但我知道
NSArray *array = [del.navigationController viewControllers];
[array objectAtIndex:3]
是我想要的视图控制器.
[array objectAtIndex:3]
is my desired view controller.
有人知道如何避免再次按下相同的视图控制器吗?
can anybody know how can i avoid this pushing of same view controller again?
推荐答案
for (UIViewController*vc in [self.navigationController viewControllers]) {
if ([vc isKindOfClass: [TestViewController class]]){
vc.itemselected= head ;
[[self navigationController] popToViewController:vc animated:YES];
}
}
* EDIT * 应该是
*EDIT*This should be
for (TestViewController*vc in [self.navigationController viewControllers])
代替
for (UIViewController*vc in [self.navigationController viewControllers])
这篇关于如何从导航控制器中的ViewController堆栈中获取特定的View Controller?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!