How to call Controller from View?

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

  • 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

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

ECEsurfer at Stack Overflow Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.