How add a custom UIView to a storyboard scene

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?

Answers


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.


Need Your Help

Differences between Octave and MATLAB?

matlab octave

This is a really beginner question, but here it goes:

Will deleting a structure's pointer also delete pointers within the structure?

c++ struct destructor delete-operator

Assume I have a structure with two pointers each pointing to an object that has an implemented destructor. Also assume that the head points to a Listnode structure that has a non-NULL value *studen...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.