0

在我的应用程序中,我从 viewController 调用了 splitViewController(请参见下面的代码)。现在我需要在 splitViewController 的顶部有一个通用视图来显示我的公司标签等。如何在顶部添加公共视图?

Appdelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.

self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; 
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = self.navigationController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}

视图控制器.m

- (void)viewDidLoad
{


[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}

-(IBAction)btnClick:(id)sender
{
PopMenuViewController *menuVC = [[PopMenuViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *menuNavController = [[UINavigationController alloc] initWithRootViewController:menuVC];

PopMenuDetailViewController *detailVC = [[PopMenuDetailViewController alloc] initWithNibName:@"PopMenuDetailViewController" bundle:nil];
UINavigationController *detailNavController = [[UINavigationController alloc] initWithRootViewController:detailVC];

menuVC.detailViewController = detailVC;

splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = @[menuNavController, detailNavController];

     self.view.window.rootViewController = splitViewController; 
}

在此处输入图像描述

4

1 回答 1

0

您可以使用流行的自定义 splitviewcontroller MGSplitViewController by Matt Gemmell

它具有通过代码设置的所有容器布局,您可以对其进行编辑,只需将主视图和详细视图向下推,并在顶部添加自定义导航栏。

于 2013-10-08T10:28:06.897 回答