1

我对 iPad 应用 SplitViewController 不太熟悉。我在我的应用程序中使用了 SplitViewController。当将方向从纵向更改为横向时,Masterview 隐藏在 splitView 中。你能帮我解决这个问题吗?

我已附上我的来源供您参考。

创建拆分视图控制器:

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // 应用程序启动后自定义的覆盖点。

menuViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController" bundle:nil];
UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:menuViewController] ;
masterNavigationController.navigationBar.barStyle = UIBarStyleBlack;

MainMenuDetailViewController *detailViewController = [[MainMenuDetailViewController alloc] initWithNibName:@"MainMenuDetailViewController" bundle:nil] ;
UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController] ;
detailNavigationController.navigationBar.barStyle = UIBarStyleBlack;


self.splitViewController = [[UISplitViewController alloc] init];
[self.splitViewController.view setBackgroundColor:[UIColor whiteColor]];
self.splitViewController.delegate = detailViewController;
self.splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil];

详情查看页面:

语用标记 -

pragma mark 拆分视图支持

  • (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController )aViewController withBarButtonItem:(UIBarButtonItem )barButtonItem forPopoverController: (UIPopoverController*)pc {

    barButtonItem.title = NSLocalizedString(@"Menu", @"Menu"); [self.navigationItem setLeftBarButtonItem:barButtonItem 动画:YES]; self.masterPopoverController = 电脑;appDelegate.rootPopoverButtonItem = barButtonItem; appDelegate.masterPopoverController = pc; }

// 当视图再次显示在拆分视图中时调用,使按钮和弹出框控制器无效。- (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {

[self.navigationItem setLeftBarButtonItem:nil animated:YES];
self.masterPopoverController = nil;

}

MasterView 按钮点击:

[appDelegate.splitViewController viewWillDisappear:YES];

[UIView  beginAnimations: @"Showinfo"context: nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.5];


NSMutableArray *viewControllerArray=[[NSMutableArray alloc] initWithArray:[[appDelegate.splitViewController.viewControllers objectAtIndex:1] viewControllers]];

[viewControllerArray removeLastObject];

if( viewMenu.hidden == YES)  // Main Menu
{
    if(btnMenu.tag == 1) // Service Report Form
    {
        if (!self.mainMenuDetailViewController) {
            self.mainMenuDetailViewController = [[MainMenuDetailViewController alloc] initWithNibName:@"MainMenuDetailViewController" bundle:nil];
        }
        [viewControllerArray addObject:self.mainMenuDetailViewController];
        appDelegate.splitViewController.delegate = self.mainMenuDetailViewController;

    }

    if(btnMenu.tag == 4) // Signout
    {
        [self.navigationItem setLeftBarButtonItem:nil];
        [appDelegate SignOut];
        btnSignOut.frame = CGRectMake(24,275,272,50);
    }
    else if(btnMenu.tag == 2) // Inquiries
    {
       if (!self.inquiryViewController) {
            self.inquiryViewController = [[InquiryViewController alloc] initWithNibName:@"InquiryViewController" bundle:nil] ;
        }


        [viewControllerArray addObject:self.inquiryViewController];
        appDelegate.splitViewController.delegate = self.inquiryViewController;
    }
    else if(btnMenu.tag == PageMasterSync)
    {

        if (!self.mastSyncViewController) {
            self.mastSyncViewController = [[MastSyncViewController alloc] initWithNibName:@"MastSyncViewController" bundle:nil] ;
        }
        appDelegate.splitViewController.delegate = self.mastSyncViewController;
        [viewControllerArray addObject:self.mastSyncViewController];
    }
    else if(btnMenu.tag == PageServiceReport)
    {
        if(!self.srListViewController)
       self.srListViewController  = [[SRListViewController alloc] initWithNibName:@"SRListViewController" bundle:nil];

        appDelegate.splitViewController.delegate = srListViewController;
        [viewControllerArray addObject:self.srListViewController];

    }


}


}


[[appDelegate.splitViewController.viewControllers objectAtIndex:1] setViewControllers:viewControllerArray animated:NO]; 
if(btnMenu.tag == PageReview &&  !viewMenu.hidden)
   [self.reviewViewController loadServiceReport];

[appDelegate.splitViewController viewWillAppear:YES];
[viewControllerArray release];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:NO];
[UIView commitAnimations];

关于森蒂尔在此处输入图像描述

4

0 回答 0