Access container's parent view from custom class

237 views Asked by At

I have a custom class myCustomClass, that is a subclass of UIView. I will be adding a UITextField as a subview. Then, in the storyboard, I set a UIView's class to the custom class.

In the storyboard, I have a viewController with a containerView. The containerView is connected to a UITalbeViewController. The UIView (that I set it's class to myCustomClass), is located in the tableViewController.

How can I add the textField as a subview of the viewController? (I know this is a bit complicating, so if you have any questions, please ask in the comments.)

Edit

Here's what I want. When you want to add a subview to the parentView, you would do the following:

[self.parentViewController.view addSubview:mySubview];

What I want to know is if there's a way to do that in a custom class file.

1

There are 1 answers

1
olynoise On BEST ANSWER

If your custom class is a subclass of UIView, it can do everything that a regular UIView can do.