views:

31

answers:

2

Hi everyone, i was just wondering wether it is possible to add an uiimageview as a .m and .h class file because you can just choose a subclass from uiview or uitableviewcell in apple's templates and it than automatically creates the .m and .h files. Is there a way to do the same for an UIImageView or is it possible to somehow "turn" the UIView into an imageview?

thanks in advance!

A: 

You could create you own subclass of UIImageView, yes. And if you're very brave, you could also create your own subclass of UIView as well, that would take a UIImage and paint that in it's -(void)drawRect: method. Then it would be much like a UIImageView.

But, why would you?

edit subclassing UIImageView is easiest by starting with the UIView subclass template, and then just replacing the word UIView with UIImageView, so you get:

@interface UIImageViewPlus : UIImageView {
    // ...
}

That's all there is to it, now just use UIImageViewPlus wherever you would use UIImageView.

mvds
The OP seems to be asking the syntax for how to do that. But, I agree, *why* is a better first question...
jtbandes
Sure? The syntax is given by XCode as the OP states. And the main question seems "how to turn a UIView into a UIImageView" (and an implied "without using UIImageView")
mvds
Yea i was asking for the syntax of a subclass of uiimageview and i want to this because in this subclass i want to define a whole bunch of labels and other stuff so these things can be accessed from other classes
Christoph v
A: 

UIImageView is a UIView since it inherits directly from UIView so I'm not sure what you are asking about.....you can easily create a subclass of the UIImageView to do whatever customization you require....

ennuikiller
Yes but how do i create that subclass?
Christoph v
@interface MyCustomUIViewClass : UIView
ennuikiller