stefano_cdn
stefano_cdn

Reputation: 1382

Add/Remove dynamically UIViews from a Storyboard's UIViewController

I'm new to IOS programming so I apologize if my question is obvious.

I created a UIViewController in storyboard, which contains a UIScrollView and multiple subviews.

These subviews (most often UITextViews) are filled with content from an external API, and content can thus be nil : in this case I would need to remove that subview which is empty.

For now I set this view as an IBOutlet and in viewDidLoad, if content is nil, I call

[self.thatView removeFromSuperView];
  1. Is there a more efficient way to do that, for instance in loadView, in order to prevent that view to even load?
  2. Is the usual method to handle subviews layoutSubviews?

Thx for your help

Upvotes: 0

Views: 693

Answers (1)

nitr0x
nitr0x

Reputation: 36

Any call before viewDidLoad will cause you problems unfortunately, you need to finish the load of a view before you dismiss it.

Upvotes: 0

Related Questions