I am creating a UIImage programmatically in my UIView’s drawRect function. Is there a way that the UIViewController responsible for this UIView access that image (or a copy of it) for manipulation?
Appreciate any pointers and thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If your UIImage you create programmatically in your drawrect is stored as a property on the UIView subclass, then the UIViewController can access the image.
Obviously, if you are using Interface Builder you’d need to wire up your UIView subclass to an IBOutlet on the UIViewController class to access the property, but I’m sure you’re doing that already.
The nonatomic retained property ensures that you’re not leaking UIImages each time the draw rect function is called.