SplitViewController的常用标头

时间:2013-10-08 10:18:02

标签: iphone ios uisplitviewcontroller ipad

在我的应用程序中,我从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;
}

ViewController.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; 
}

enter image description here

1 个答案:

答案 0 :(得分:0)

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

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