1

UISplitViewControllerを4番目の位置(つまり4番目のビュー)に配置する6つのビューがあります。ここで、3番目のビューから4番目のビュー(つまり、ViewControllerからSplitView)に移動するときに、4番目のビューから3番目のビュー(つまり、SplitViewからViewController)に戻りたいと思います。

以下のコードを使用して、3番目のビューから4番目のビューに移動するときにUISplitViewControllerを表示しています。

MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
            UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];

            DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
            UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController];

            masterViewController.detailViewController = detailViewController;
            self.splitViewController = [[UISplitViewController alloc] init];
            self.splitViewController.delegate = detailViewController;
            self.splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil];
            AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
            appDelegate.window.rootViewController = self.splitViewController;

これで、ナビゲーションバーにプログラムでツールバーを作成し、戻るボタンを配置しました。以下は、ビューをviewcontrollerにポップバックしようとしたコードです。(つまり、SplitViewからViewControllerへ)。

-(IBAction)backbtn:(UIBarButtonItem *)sender
{
//    RepresentativeAccount<UISplitViewControllerDelegate> *represent = [[RepresentativeAccount alloc]initWithNibName:@"RepresentativeAccount" bundle:nil];
//    //[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES];
//    [[self.splitViewController.viewControllers objectAtIndex:0]popToViewController:represent animated:YES];
}

感謝を助けてください。

4

1 に答える 1

0

Reference: View Controller Catalog for iOS

A split view controller must always be the root of any interface you create.

In other words, you must always install the view from a UISplitViewController object as the root view of your application’s window.

The panes of your split view interface may then contain navigation controllers, tab bar controllers, or any other type of view controller you need to implement your interface.

Split view controllers cannot be presented modally.

So, what you are attempting is incorrect, and in fact your app may get rejected by Apple.

于 2012-04-25T13:20:17.250 に答える