Search code examples
iosobjective-cuiviewcontrollercohesion

embed multiple view controller in one window


I want to have a View which contains more than one view. see the below image: enter image description here

as you see pageController controls page navigation and provide before and after viewController (page).

pageContentController displays text and process them.

soundPlayer manages playing related sound

I can have all of them in one controller, but my controller must do a lot of tasks and managing it will be hard task. as it disobey light view controller. and decrease its cohesion. so I wanted to know how can I accomplish this please explain in details.


Solution

  • thanks for your detailed answers. your answers clarified me. what I did:

    I added SoundPalyerVC as child of PageContentVC

    SoundPlayerVC *soundPlayer = [[StoryViewController alloc] initWithStory:self.storyManagedObject];
    [self addChildViewController:soundPlayer];
    [self.view addSubview:soundPlayer.view];
    [soundPlayer didMoveToParentViewController:self];
    soundPlayer.view.frame = CGRectMake(0, self.view.frame.size.height-soundPlayer.view.frame.size.height, 320, soundPlayer.view.frame.size.height);
    

    that was so easy. now my codes are separated.