How do I call a view controller method from another class in iOS?

2.8k views Asked by At

I have a toolbar object that inherits from UIView and is a subview of "CanvasView" on the bottom of the screen on an iPad app.

Basically I have buttons on this subview that should draw an image onto CanvasView, it's superview. I have tried many different things but nothing draws the image and I don't ever get errors to tell me what I am doing wrong.

Are there any permissions I need to give my toolbar so that it can draw on the view?

many thanks in advance

1

There are 1 answers

0
onetwopunch On BEST ANSWER

As PengOne said, it was definitely a delegation issue. If you have a view controller that owns another class, and you want to access a method in the view controller from that class you need to set the view controller as a delegate of the class (Please correct me if I'm getting the terminology wrong). Anyway, the code works perfectly now thanks to this site:

http://www.ios-developer.net/iphone-ipad-programmer/development/delegates/how-to-create-a-delegate

And thank you PengOne for the starting point!