How to draw something on UIImageView in UIViewController Class - iphone

I know a method to draw on iPhone using UIView class and UIImage method. But can i draw inUIViewController class on UIImageView?

As UIImageView is a subclass of UIView, you should be able to use the exact same method to do what you want.
You might also add a custom view (inherit from UIView) above any other view and draw anything you want on that view.

Related

Who to implement UIBezierPath class in the UIViewController class?

Why i can't using UIBezierPath class in UIViewController class directly without using any View class ?
Because you can't draw on a controller, you draw on a view. To demonstrate, If UIBezierPath class is a pen, the view is your paper and the code you put in the view's dreawRect() method is like your hand which uses a pen (UIBezierPath) to draw.
The viewController is so unrelated that you can say its a bag for your papers.

iPhone - extend UIImage for custom drawing at runtime

How can I subclass and draw on an UIImage directly?
I tried extending it and draw on drawAtPoint: or drawInRect: using CoreGraphics, but the image is blank. And neither of the above 2 draw methods are called.
Please don't answer me that I can draw on the UIView because I need a custom runtime designed UIImage.
It's clearly stated in the UIImageView document:
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIImageView_Class/Reference/Reference.html
Subclassing Notes Special Considerations
The UIImageView class is optimized to draw its images to the display.
UIImageView will not call drawRect: a subclass. If your subclass needs
custom drawing code, it is recommended you use UIView as the base
class.
Because telling you to use UIView instead is now allowed, I'll just answer that it's impossible to override drawRect: for UIImageView.

iphone draw over UIScrollView with MultiTouch

I'm creating methods to use multi-touch taps to draw shapes on top of an image inside a UIScrollView. I'm thinking that I should just create a new UIView subclass for the shapes and add them as a subView to the main controller that contains the scrollView.
If so, can I simply use touchesBegan, touchesMoved, ... with the new UIView subclass? And if not how do I connect the touches to the drawing logic.
Thanks!
To get the touch method in UIScrollView you need to make your own class for Scrollview which is sub class of the UIscollview and use that class in place of the UIScrollView. As you class is Sub class of UIScrollView you can get all the method of the UIScrollView through object of you class.
Now for getting touch method you will get in you class and using custom delegate you can call in any class.

Drawing a line in a UIView subview

I have a UIView subclass. This subclass has multiple subviews. Is it possible to draw a line using core graphics inside a subview that is part of the uiview subclass?
For example, I have a SampleView class, which is a subclass of UIView. Inside this class's header file is the property for UIView *sampleSubView, which is a subview of SampleView. Is it possible to draw a line inside of sampleSubView from the SampleView class implementation?
Thanks for your help!
Josh
If you are asking how a UIView subclass can draw a line on itself, then see the Quartz demo sample code. Basically, you'll override the view's drawRect: method, get the current graphics context, then draw whatever you like onto it.
If you are asking how one view can draw a line on another view, perhaps you need to rethink your architecture.

iPhone Sdk: Is it possible to add an UIImageView as a file?

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!
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.
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....