3
votes

I have a UIViewController subclass A that is a container of other view controllers. The contained view controllers' view is placed in a container view of A. A's container view is full-screen. A also has an accessory view in the form of a custom bar that overlaps the bottom part of the container view, similar to a UIToolbar.

When I add a view controller B as a child of A, and A places B's view in its container view, I'd like B's view to respect A's accessory views automatically. For example, if B is a UITableViewController, I would like B's UITableView to automatically have its content insets modified to respect A's accessory view.

Is there a way to configure A so that B's view automatically does this? Or does A have to manually modify B's view when B is added to A?

I have tried to override A's top/bottomLayoutGuide to return my own layout objects. This doesn't seem to work as -topLayoutGuide/-bottomLayoutGuide don't seem to ever get called, and the properties are read only so you can't just set your own layout guides.

What's the best way to do this that doesn't require A to have intimate knowledge of B's views?

1
Can you add a bit of code?footyapps27

1 Answers

-1
votes

You have a lot of options here.

First, why not resize A's containerView so that the bottom bar doesn't overlap it?

Second, you could add a subview to the container view that isn't overlapped, and add views to that instead.

And those are just the easy ways.