开发者

iPad Split View Call/Load from another view

开发者 https://www.devze.com 2023-04-08 11:06 出处:网络
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..?

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


i m do this type but i am not get split view

  • (void)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;

    //first.detail=detail;

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

    window1 = [appDel window];

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

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

    [window1 addSubview:split.view];

    // Do any additional setup after loading the view from its nib. }

0

精彩评论

暂无评论...
验证码 换一张
取 消