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
Related Q & A:
- How do I call an objective-c method?Best solution by Stack Overflow
- how to call a function in Python in another function?Best solution by Yahoo! Answers
- How do I install a ps3 controller on my PC?Best solution by Yahoo! Answers
- How do I call a cell phone in Australia?Best solution by wiki.answers.com
- How do i use a Gamecube controller on the Pc?Best solution by Quora
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.