Trzy Gracje
Trzy Gracje

Reputation: 3069

How to add tab bar controller to the subview in iOS?

Is there any way to add a tab bar controller to a subview of the iPad app? Below is the screen that shows what I am talking about: enter image description here

When I try to add tab bar controller to the view its showing on the whole width of the screen.

Upvotes: 0

Views: 538

Answers (1)

Tiemen
Tiemen

Reputation: 894

Due to the autoresizing mask of the view of the tab bar controller, it will assume the full size of its superview.

Either manually edit the frame or autolayout constraints of the view of the tab bar controller (when instantiating the tab bar controller or in viewDidLayoutSubviews) or add it to a child view that has a frame equal to the grey area in your image.

If you set the frame when instantiating the tab bar controller, be sure to change the autoresizingMask property of the tab bar's view so that it doesn't have flexible width or flexible right margin.

Upvotes: 1

Related Questions