如何在按钮单击时显示UISplitViewcontroller

时间:2012-10-04 04:54:41

标签: iphone objective-c ipad

有没有办法在按钮点击时显示UISplitViewController

1 个答案:

答案 0 :(得分:0)

请使用以下代码..

@interface ...

-(IBAction)Btn_OpenSplitView:(id)sender;

@end

@implementation ...

-(IBAction)Btn_OpenSplitView:(id)sender { 
    UIViewController* secondVC = [[UIViewController alloc] initWithNibName:@"ContentView"
                                                                    bundle:nil];

    UIViewController* firstVC = [[UIViewController alloc] initWithNibName:@"MenuView"
                                                                   bundle:nil
                                                withContentViewController:secondVC];

    UISplitViewController* splitVC = [[UISplitViewController alloc] init];
    splitVC.viewControllers = [NSArray arrayWithObjects:firstVC, secondVC, nil];

    [self addSubview:splitVC.view];   
}

@end