2012-07-10 106 views
0

我有一个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.'不知道看到这是否与我的问题,如果是这样,如果有办法解决它。

非常感谢,

回答

1

这是正常的,一个模式的看法应该是这种方式工作

Apple Documentation

呈现视图控制器的能力是你有在您的处置工具用于中断当前工作流程并显示一组新的视图。通常,应用会将视图控制器呈现为临时中断,以便从用户获取关键信息。但是,您也可以使用提供的视图控制器在特定时间为您的应用程序实现备用界面。

在您的didSelectRowAtIndexPath方法,你可以使用类似

YourAppNameDelegate *appDelegate = (YourAppNameDelegate *)[[UIApplication sharedApplication] delegate]; 
[appDelegate tabBarController].selectedIndex = 0; 
+0

谢谢卢卡斯,那效果很好。但是,我将如何通过我的方法'[passThisAlong:@“id”]'。在之前它像'FirstViewController * firstViewController = [[FirstViewController alloc] initWithNibName:@“FirstView”bundle:[NSBundle mainBundle]]; [firstViewController passThisAlong:@“id”];'我将如何使你的例子工作? – Nathan 2012-07-10 15:03:38

+0

我会在第一个viewController上创建一个属性,然后你可以设置它的属性。 – Lucas 2012-07-10 15:05:55

+0

或者你可以使用代表团,我认为这将是整洁的 – Lucas 2012-07-10 15:06:27

1

现在的模式视图以这种方式工作。为什么你不能使用基于标签的应用程序?

+0

只是尝试和喜欢的人,如果我做'[自我presentModalViewController:smartPicViewController动画:是];'它不显示的TabBar – Nathan 2012-07-10 15:09:16

+2

当前模式的看法会利用整个屏幕。你可以去基于Tab +导航的应用程序:-) – Nina 2012-07-10 15:11:03

相关问题