9

I created a UIView with an image view inside it. Gave it a name of "XXXMyView".

in my storyboard view controller, i dragged a UIView on to the View Controller (scene) and then set its class to XXXMyView.

But when I do I don't see the image view, but's just the background color.

How can I make it where I see my view I created on the screen that shows the image view?

1
  • 1
    I suggest showing the code of the XXXMyView class Commented Sep 7, 2012 at 15:03

3 Answers 3

4

What you should do is create an empty UIView in your storyboard. Drag a UIImageView on your view.

Then create a subclass of UIView. In the storyboard, set the class of your view to match your recently created class. Open the editor window (top right of the main project window, middle button of the "editor" section). Put the XXXView.h on the left window, and your storyboard on the right. ctrl-drag from your UIImageView to your .h (between @interface and @end). Give it a name. You created a link between your visual representation of the UIImageView and your code. You can now access it from your .m file.

Ray Wenderlich has a pretty neat tutorial on storyboards. Here are Part 1, and Part 2.

Sign up to request clarification or add additional context in comments.

Comments

0

Perhaps you need to set the "view" outlet of the UIViewController to the new XXXMyView.

2 Comments

The problem is that the XXXMyView is a child of the Main view in the storyboard. Doing that makes it the parent view.
OK I understand. Is it not possible to set the XXXMyView as the main. Since UIImageVIew is a subclass of UIView this one could also be set as the "Main" view for your UIViewController. Perhaps submitting a screenshot of your storyboard layout will clarify your setup.
0

I think your looking at this the wrong way (from what I understand)

  1. See the UIViewController as the "main" view and use it's class to manipulate the subviews (the UIView and UIImageView)

  2. Link your UIView and UIImageView as objects inside your UIViewController class and use those objects to do what you need to (add new subviews dynamically or edit properties etc.)

  3. You can add subviews to a UIView by using [yourViewObject addSubview: (UIView *)]. Don't be fooled by the (UIView *) you can use any subclass of UIView as an argument. (e.g. an UIImageView object)

If you don't know how to link (or reference) the objects from the storyboard to the class I would sugest to work through Ray Wenderlich's tutorials on storyboarding as rdurand sugested. Here's the link again Part 1.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.