0

I have a chat that's setup as a UIViewController with a tableView added to it's view. This was working fine. I've since subclassed this viewController and added a childViewController as a header of the table:

- (void) createClassVideoView {

        CGRect rect = CGRectMake(0.0f,
                                 0.0f,
                                 self.view.frame.size.width,
                                 kWSClassVideoHeight);

        WSClassVideoController *classVideoController = [[WSClassVideoController alloc] initWithFrame:rect mainUser:[[WSConversationManager shared] teacherObject] secondaryUsers:[[WSConversationManager shared] students]];
        [self addChildViewController:classVideoController];
        [self.view addSubview:classVideoController.view];
        [classVideoController didMoveToParentViewController:self];
        self.classVideoController = classVideoController;

}

It's not set as the actual tableHeaderView. It's just added as a childViewController to the subclass of the chat view controller, and I've just reset the frame of the tableView to accomodate it. This "header view" works fine and receives touches.

However, it's since disabled the superclass tableView's touches. The tableView displays, but I can't scroll it and tapping the UITextField does nothing.

OdieO
  • 6,836
  • 7
  • 56
  • 88
  • You cannot add view controllers as children of other view controllers. – Michael Dec 20 '14 at 03:17
  • @Nikita, sure you can. What do you think the method, addChildViewController: does? – rdelmar Dec 20 '14 at 04:14
  • @rdelmar You can, but that probably isn't what the OP wants to do... – Paulw11 Dec 20 '14 at 04:29
  • You never set the frame of classVideoController's view. Don't you want to set it to rect? If you do that, does it help? – rdelmar Dec 20 '14 at 04:46
  • @Paulw11, what makes you think so? That is what he says he's trying to do. – rdelmar Dec 20 '14 at 04:47
  • Because `addChildViewController`'s documentation states - "This method is only intended to be called by an implementation of a custom container view controller." In this instance a UIView subclass would probably be more appropriate – Paulw11 Dec 20 '14 at 04:50
  • @Paulw11, by using the custom container controller api, which the OP is, then his controller is a custom container controller. Maybe a UIView subclass would be more appropriate, but without knowing what he's doing in this view, it's hard to know. – rdelmar Dec 20 '14 at 04:52
  • @rdelmar @Paulw11 The first thought was to just make this video view the `tableHeaderView` but there's a lot of distinct functionality going on in it. It's pretty much a video chat component and the chat superclass is a text-based messaging component... What I'm going to try now is implementing a distinct parent UIViewController and then adding BOTH the videoClassVC and the chatVC as child VCs. – OdieO Dec 20 '14 at 18:24
  • I just switched the hierarchy around and made the `classVideoController` the parent VC and the chatVC the child, which makes more sense anyway. Touches now work on both. Don't know what the root problem was though. – OdieO Dec 20 '14 at 20:09

0 Answers0