2011-09-27 144 views
2

请帮我解决下面提到的问题。iPad拆分视图从另一个视图调用/加载

我的问题是,是否有办法从另一个视图调用拆分视图,比如我点击一个按钮后说......?

例如,如attached pic所示,当应用程序启动时,它会显示第一个屏幕。

当用户点击“单击”按钮时,分割视图打开。

用户能够执行分割视图的所有操作,并且当他按下主页按钮时,他应该被带回第一个屏幕。

这是可能的..?我怎么去解决它..?

我是初学者。任何帮助代码将不胜感激..

PS:我已经尝试使用MGSplitView和TOSplitView,但一直未能实现上述问题的解决方案。

谢谢...

回答

3

检查foll代码。这应该很容易帮助你解决你的问题。

//Intialise the 2 views root and detail 
    RootViewController * rootVC = [[RootViewController alloc] initWithStyle:UITableViewStylePlain]; 

    //To show the nav bar for root, add it into a UINavigationController 
    UINavigationController * rootVCNav = [[UINavigationController alloc] initWithRootViewController:rootVC]; 


    DetailViewController * detailVC = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil]; 

    //initialise split view 
    splitVC = [[UISplitViewController alloc] init]; 
    splitVC.viewControllers = [NSArray arrayWithObjects:rootVCNav,detailVC, nil]; 

    //Tell the split view that its delegate is the detail view. 
    splitVC.delegate = detailVC; 
    //tell root that the changes need to be shown on detail view. 
    rootVC.detailViewController = detailVC; 


    [rootVC release]; 
    [detailVC release]; 
    [rootVCNav release]; 

    //Here, we get the app delegate object of the project 
    ProjectAppDelegate * appDel = (ProjectAppDelegate*)[[UIApplication sharedApplication] delegate]; 

    //get window object of the delegate 
    UIWindow * window1 = [appDel window]; 
    //get the navigation controler of the window of app delegate. 
    mainNav = [appDel rVC]; 

    //remove the current view from the window. 
    [mainNav.view removeFromSuperview]; 

    //add the split view to the window 
    [window1 addSubview:locSplitVC.view]; 

希望这有助于你..

问候, 梅尔文

+0

谢谢梅尔文.. 这仅仅是完美.. !!! –

1

IM做这种类型的,但我没有得到拆分视图

  • (无效)viewDidLoad中 { [super viewDidLoad]; MainViewController * first = [[MainViewController alloc] initWithNibName:@“MainViewController”bundle:nil];

    UINavigationController * sec = [[UINavigationController alloc] initWithRootViewController:first];

    DetailViewController * detail = [[DetailViewController alloc] initWithNibName:@“DetailViewController”bundle:nil]; UINavigationController * detailv = [[UINavigationController alloc] initWithRootViewController:detail];

    UISplitViewController * split = [[UISplitViewController alloc] init];

    split.viewControllers = [NSArray arrayWithObjects:sec,detailv,nil];

    // split.delegate = detail;

    split.delegate = self;

    //首先。详细=细节;

    appDel =(AppDelegate *)[[UIApplication sharedApplication] delegate];

    window1 = [appDel window];

    UINavigationController * mainNav = [[UINavigationController alloc] init];

    mainNav = [appDel nav]; [mainNav.view removeFromSuperview];

    [window1 addSubview:split.view];

    //在从其笔尖加载视图后执行任何其他设置。 }

相关问题