Fas*_*ser 7 objective-c uitabbarcontroller ipad uisplitviewcontroller ios
我想让我的内容splitviewController显示在一个TabBarController.不幸的是,我首先决定只SplitViewController选择苹果的模板.现在我处于不方便的位置,不知道如何将其添加到标签栏.
我尝试了几个在StackOverflow上解释的东西,但最好的结果是一个黑色的屏幕下面有一个标签栏:-(
我正在努力寻找一种美好而简单的方法.
我的代码Appdelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Add the split view controller's view to the window and display.
self.window.rootViewController = self.splitViewController;
[self.window makeKeyAndVisible];
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
documentFolderPath = [searchPaths objectAtIndex: 0];
self.rootViewController.directoryPath = documentFolderPath;
NSURL *docUrl = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
if ([docUrl isFileURL]) {
NSString *path = [docUrl path];
self.detailViewController.currentFilePath = path;
[self.detailViewController setDetails:path newFile:FALSE];
}
return YES;
Run Code Online (Sandbox Code Playgroud)
您应该检查IntelligentSplitViewController是您需要的一切!
添加一些控制器和设计你可以这样结束:

PS:我实际上在App Store中有一个使用这个控制器的应用程序,所以去吧!
编辑:
我刚刚意识到你实际上想要在tabbar中使用splitview.根据苹果文档,这是一个不. http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/iPadControllers/iPadControllers.html
拆分视图控制器必须始终是您创建的任何接口的根.换句话说,您必须始终从aUISplitViewController对象安装视图作为应用程序窗口的根视图.然后,拆分视图界面的窗格可能包含导航控制器,标签栏控制器或实现界面所需的任何其他类型的视图控制器.
如果你仍然想使用tabbar我下面写的东西仍然适用,但你的子视图不应该是splitview控制器.
原始答案:
您将在代码中创建tabbar控制器,然后将splitview控制器添加为其中一个选项卡.在您的情况下,self.splitViewController将成为您的tabbar控制器中的一个视图控制器.我没有尝试使用苹果模板应用程序作为起点,但给它应该工作.
您可以在uitabbarcontroller上查找有关更多信息的教程.这看起来很有希望:http://www.xcode-tutorials.com/uitabbarcontroller-and-uinavigationcontroller/
这也很方便:http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITabBarController_Class/Reference/Reference.html
下面是一个样本:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UITabBarController *tabBarController = [[UITabBarController alloc] init];
//set tbconroller as root view controller of window
[self.window setRootViewController:tabBarController];
//window retains controller so we can release
[tabBarController release];
//create two view controllers
UIViewController *vc1 = [[HypnosisViewController alloc] init];
UIViewController *vc2 = [[CurrentTimeViewController alloc] init];
//make an array containing these two view controllers
NSArray *viewControllers = [NSArray arrayWithObjects:vc1,vc2,nil];
[tabBarController setViewControllers:viewControllers];
//the views are retained their new owners, so we can release
[vc1 release];
[vc2 release];
[[self window] makeKeyAndVisible];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
如果你正在使用界面构建器,这里有一些教程http://www.cimgf.com/2009/06/25/uitabbarcontroller-with-uinavigationcontroller-using-interface-builder/ 或http://www.mobisoftinfotech .COM /博客/ iphone/iphone-的TabBar-的UITabBarController教程/
从苹果的文档来看,这是一种不可以的情况。
但有一种方法可以轻松实现这一点(我们为应用程序做到了)。
看看http://www.codeworth.com/blog/mobile/ios-splitviewcontroller-inside-tabviewcontroller/
我认为这就是这个问题的恰当答案。
| 归档时间: |
|
| 查看次数: |
9552 次 |
| 最近记录: |