我对 iPad 很陌生UISplitViewController
。
我需要在主视图/左视图的底部添加一个包含 3 个选项卡的选项卡栏。对于 3 个选项卡中的每一个,我都有一个不同的视图控制器。我还没有找到在基于拆分视图的应用程序中使用标签栏的任何其他示例。
在哪里插入标签栏控制器以显示在根视图的底部?
如何建立连接,以便当我选择表格单元格时,detailItem 信息会显示在详细信息视图中?选项卡栏已添加到 IB 的根视图中。我应该以编程方式添加它吗?
我对 iPad 很陌生UISplitViewController
。
我需要在主视图/左视图的底部添加一个包含 3 个选项卡的选项卡栏。对于 3 个选项卡中的每一个,我都有一个不同的视图控制器。我还没有找到在基于拆分视图的应用程序中使用标签栏的任何其他示例。
在哪里插入标签栏控制器以显示在根视图的底部?
如何建立连接,以便当我选择表格单元格时,detailItem 信息会显示在详细信息视图中?选项卡栏已添加到 IB 的根视图中。我应该以编程方式添加它吗?
在您的应用程序委托中添加标签栏控制器,然后将您的视图控制器添加到标签栏控制器并将窗口根视图控制器设置为标签栏控制器。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.tabbar=[[UITabBarController alloc] init];
self.vc1 = [[vc1 alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
// do the same to other VCs
self.tabbar.viewControllers=[NSArray arrayWithObjects:vc1,vc2,vc3,vc4, nil];
self.window.rootViewController = self.tabbar;
[self.window makeKeyAndVisible];
return YES;
}
我希望它有帮助:-)
你必须动态地使用 UITabBarController。
在 .h 文件中
UITabBarController *tabBar;
在 .m 文件中
在 appDidFinish Launch 中为您的类创建对象
例如你有
1 类和 2 类
在 appDidFinishLaunch 中
Class1 *obj1=[Class1 alloc]initWithNibName:@"Class1" bundle:nil]; **Class2 obj2=[Class2 alloc]initWithNibName:@"Class2" bundle:nil]; *
// 主导航控制器默认自带模板代码
// 现在你已经为 tabBar 创建了数组
NSArray *tabViewArray=[[NSArray alloc] initWithObjects:obj1,obj2,masterNavigationController, nil];
tabBar=[[UITabBarController alloc] 初始化];
[tabBar setViewControllers:tabViewArray];
// 现在你必须用 tabBar 编辑包含 splitview.viewArray repalce masterNavigataionControler 的语句
self.splitViewController.viewControllers = [NSArray arrayWithObjects:tabBar, detailNavigationController, nil];
试试这个我希望它会帮助你。
您所要做的就是将uispliviewcontroller 的第一个参数初始化为选项卡而不是视图,或者您可以使用uisegmentedcontrol。