Hayley
Hayley

Reputation: 51

How to add UITextView as a subview to UIImageView on interface builder?

I have created a UIImageView and I want to add a UITextView as a subview beneath the image. Is there any way that I can configure this using the Interface Builder instead of hardcoding it? If not, in which part of the code should I insert the subview to and what else do I need to change?

Upvotes: 2

Views: 3133

Answers (3)

Srikar Appalaraju
Srikar Appalaraju

Reputation: 73688

Yes you can do it in Interface Builder - see the image

enter image description here

To get this view, at the bottom there is an < arrow image. Click to get this. After that its drag your UI element underneath any other element to add that element as a subview of that UI element...

Of course you can do this in code by simply writing [someView addSubView:newView];

Upvotes: 0

arsenius
arsenius

Reputation: 13276

You should just be able to do:

[myImageView insertSubview:myTextView atIndex:0];

If you want it actually to be "part of" the UIImageView I don't think you can do it in Interface Builder. But this is a normal method of extending UIKit views.

Upvotes: 0

Create View and then put both of them inside of that.

View-->

    |
    --->imageView
    |
    --->textView

Upvotes: 3

Related Questions