How do I create reusable iOS controls?

Viewed 10675

As a new iOS developer I am trying to determine the best approach to creating reusable controls in iOS4+. For example if I wanted to create a customized UIImageView that could be used in multiple other views what is the best approach.

I have created the control including the following files:

  • MyImageViewController.h
  • MyImageViewController.m
  • MyImageViewController.nib

Assume that I want a control that utilizes a .nib file.

How would I do the following:

  1. Create an instance of the custom control in another view, programmatically and via IB?
  2. How do I structure the custom control so it can expose "events", e.g., ontouch?
  3. How do I structure the custom control so I can call actions/methods, e.g., loadImage()?

Any insights or reference appreciated. Thanks

3 Answers
Related