Domanda

i want to "unload" view controllers so they get read each time a user click on them in the uitableview it's a uisplitviewcontroller with childviewcontrollers how is this possible ?

-(void)Graviditeten:(int)viewId {
UIViewController *viewController;
switch (viewId) {
    case 0:
        viewController = self.jegKomTil;
        break;
    case 1:
        viewController = self.scannet1;
        break;
    case 2:
        viewController = self.ugeForUge;
        break;
    case 3:
        viewController = self.opfoeselIMave;
        break;
    case 4:
        viewController = self.specielleMinderGravid;
        break;
    case 5:
        viewController = self.nakkefold;
        break;
    case 6:
        viewController = self.mdScan;
        break;
    case 7:
        viewController = self.madMorHave;
        break;
    case 8:
        viewController = self.tingFar;
        break;
}
[self showChildViewController:viewController];
}


-(void)showChildViewController:(UIViewController*)content {
if(topController != content) {
    content.view.frame = [self.view frame];
    [self.view addSubview:content.view];
    [content dismissViewControllerAnimated:YES completion:nil];
    [content didMoveToParentViewController:self];
    [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];

    topController = content;
}
}

so far i tried this in the ShowChildViewController

[content dismissViewControllerAnimated:YES completion:nil];

but then it shows nothing

È stato utile?

Soluzione 2

-(void)showChildViewController:(UIViewController*)content {
if(topController != content) {
    content.view.frame = [self.view frame];
    [content.view removeFromSuperview];
    [self.view addSubview:content.view];
    [content.view setNeedsDisplay];
    [content didMoveToParentViewController:self];

    topController = content;
}
}

This works!

Altri suggerimenti

It sounds like you don't really want to unload the vc's view, but rather to refresh when it's about to be presented. The UISplitViewControllerDelegate gets notified with splitViewController:willShowViewController:invalidatingBarButtonItem before a vc is shown. The vc being shown is a parameter. See doc here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top