我有一个tabBarController
,我通过将下面的代码添加:iPhone - 通过UITabBarItem和dismissModalViewController presentModalViewController干净
AppDelegate.h:
...
UITabBarController IBOutlet *tabBarController;
}
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
AppDelegate.m:
...
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
[tabBarController setDelegate:self];
然后我用下面的代码来呈现一个模式条形码扫描的视图控制器:
- (void)tabBarController:(UITabBarController *)tbc didSelectViewController:(UIViewController *)vc {
// Middle tab bar item in question.
if (vc == [tabBarController.viewControllers objectAtIndex:2]) {
ScanVC *scanView = [[ScanVC alloc] initWithNibName:@"ScanViewController" bundle:nil];
// set properties of scanView's ivars, etc
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:scanView];
[tabBarController presentModalViewController:navigationController animated:YES];
[navigationController release];
[scanView release];
}
}
当它真正得到展示我觉得这个方法不够吸引人,因为当我关闭该模式的看法,我把回到空视图。
许多条码扫描应用程序或应用程序,例如简单地显示图像选择器;做得很成功。我只是想知道为了达到这样的效果他们会用什么样的实现。
这就是所谓的路径的应用程序的截图,其中有完全相同的功能,我以后:
我还注意到,在这些应用中,如果你在其他任何比中间的一个标签栏项目,我们可以说,并且您单击显示模式视图的标签栏项目,一旦它被解散它实际上不会将它们带回到它视为正常的空白视图,但实际选项卡显示模态视图的酒吧项目从未被选中。如果这是实现这种类型效果的唯一方法,我会对这种类型的功能感到满意。
任何帮助将不胜感激,因为我一直坚持了很长一段时间。此外,我甚至不确定是否将所有代码放入我的AppDelegate
以便将View Controller作为模式呈现的正确方法。这一切似乎都是错的。
我想你会发现Path应用程序使用自己的标签栏控制器实现。即不是来自Cocoa Touch的`UITabBarController` – ohhorob 2011-01-17 04:21:52