1
votes

I currently have a UIViewController which contains a menu bar and container UIView.

On main view load the container has an embed segue with a separate main content UIViewController.

When I click a button in the menu bar I have a custom segue set up to load a UITableViewController into the UIView container using the following code

-(void) perform {
    BlockDetailViewController *src = (BlockDetailViewController *)[self sourceViewController];
    UIViewController *dst = (UIViewController *)[self destinationViewController];

    //Clear view of all subviews
    for (UIView *view in src.viewContainer.subviews) {
        [view removeFromSuperview];
    }
    //save destination
    src.currentViewController = dst;

    //set placeholderOutlet to destination
    [src.viewContainer addSubview:dst.view];
}

This loads the UITableViewController into the UIView fine, however, it seems the UITableViewController size is set as the default window size which means the bottom cells of the UITableViewController are hidden from view. You can see them if you drag up but when you let go the bounce takes them out of the view.

How do I make sure the size of the UITableViewController is the same size as the UIView it is being placed into?

Thanks

2

2 Answers

0
votes

When you define dst, you can use CGRect to set its position, width and height.

0
votes

You just have to create a a CGRect (frame) and set it to the views frame:

dst.view.frame = CGRectMake( CGRectGetMinX(self.view.frame),
                             CGRectGetMinY(self.view.frame), 
                             CGRectGetWidth(self.view.frame), 
                             CGRectGetHeight(self.view.frame);

the values should be float values. This is just an example.