我有一个iPhone应用程序,在我所有的视图上都使用了一个tabbar。 此外,我的第一个视图控制器没有navigationBarController,但我的第二个视图,以及tabbar。presentViewController不显示tabbar
我的第二个视图控制器是一个tableview,当我点击其中一个单元格时,我想要带到第一个视图控制器(通过它传递一个参数)。
我已经尝试了几种处理方法,这些方法都适用,但不要。
secondViewController.m
FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstView" bundle:[NSBundle mainBundle]];
[firstViewController passThisAlong:@"id"];
//[self presentViewController:firstViewController animated:YES completion:nil]; //1
[self.navigationController pushViewController:firstViewController animated:YES]; //2
//[self.tabBarController presentViewController:firstViewController animated:YES completion:nil]; //3
[firstViewController release];
firstViewController = nil;
所以你可以在上面看到,我试过3种不同的获取到的第一个视图控制器的方法。 第二个加载第一个视图,在第二个视图内向下钻取,因为它使nagigationBarController(即使第一个视图没有一个)与第二个视图的后退按钮保持一致。
其他两个彼此做同样的事情。哪一个是第一个视图(没有导航栏),但是,没有tabbar,第一个视图的内容已经向上移动了tabbar的高度,在它的位置只是黑色。
我希望这一切都有道理。我希望能够从我的第二个视图去选择某个表格中的某个单元格时,我的第一个视图就好像我点击了tabbar中的图标。
我的文档 'On iPhone and iPod touch, the presented view is always full screen. On iPad, the presentation depends on the value in the modalPresentationStyle property.'
不知道看到这是否与我的问题,如果是这样,如果有办法解决它。
非常感谢,
谢谢卢卡斯,那效果很好。但是,我将如何通过我的方法'[passThisAlong:@“id”]'。在之前它像'FirstViewController * firstViewController = [[FirstViewController alloc] initWithNibName:@“FirstView”bundle:[NSBundle mainBundle]]; [firstViewController passThisAlong:@“id”];'我将如何使你的例子工作? – Nathan 2012-07-10 15:03:38
我会在第一个viewController上创建一个属性,然后你可以设置它的属性。 – Lucas 2012-07-10 15:05:55
或者你可以使用代表团,我认为这将是整洁的 – Lucas 2012-07-10 15:06:27