iPad拆分视图从另一个视图调用/加载 [英] iPad Split View Call/Load from another view

查看:84
本文介绍了iPad拆分视图从另一个视图调用/加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我解决下面提到的问题。



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



例如,如附加图片,当应用启动时,它会显示第一个屏幕。



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



用户可以执行拆分视图的所有操作,当他按下主页按钮时,他应该被带回第一个屏幕。 / p>

这可能吗??我该怎么办......?



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



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



谢谢...

解决方案

检查foll代码。这很容易帮助您解决问题。

  //初始化2个视图根和详细信息
RootViewController * rootVC = [[RootViewController alloc] initWithStyle:UITableViewStylePlain];

//要显示root的导航栏,请将其添加到UINavigationController
UINavigationController * rootVCNav = [[UINavigationController alloc] initWithRootViewController:rootVC];


DetailViewController * detailVC = [[DetailViewController alloc] initWithNibName:@DetailViewbundle:nil];

//初始化拆分视图
splitVC = [[UISplitViewController alloc] init];
splitVC.viewControllers = [NSArray arrayWithObjects:rootVCNav,detailVC,nil];

//告诉拆分视图其委托是详细视图。
splitVC.delegate = detailVC;
//告诉root需要在详细视图上显示更改。
rootVC.detailViewController = detailVC;


[rootVC发布];
[detailVC release];
[rootVCNav release];

//这里,我们得到项目的app delegate对象
ProjectAppDelegate * appDel =(ProjectAppDelegate *)[[UIApplication sharedApplication] delegate];

//获取委托的窗口对象
UIWindow * window1 = [appDel window];
//获取app delegate窗口的导航控制器。
mainNav = [appDel rVC];

//从窗口中删除当前视图。
[mainNav.view removeFromSuperview];

//将拆分视图添加到窗口
[window1 addSubview:locSplitVC.view];

希望这可以帮助你..



此致,
Melvin


Please help me with the issue mentioned below.

My issue is, whether there is way to call the split view from another view, say after I tap on a button..?

For eg, as shown in the attached pic, when the app launches, it shows the first screen.

When the user taps on "Click" button, the split view opens up.

The user is able to perform all operations of the split view and when he presses the Home Button, he should be taken back to the first screen.

Is this possible..? How can I go about it..?

I am a beginner. Any help with code would be greatly appreciated..

PS: I have tried using MGSplitView and TOSplitView, but have not been able to achieve the solution to the above mentioned issue.

Thanks...

解决方案

Check the foll code. This should easily help you to solve your issue.

   //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];

Hope this helps you..

Regards, Melvin

这篇关于iPad拆分视图从另一个视图调用/加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆