is it possible that a UIView calls a method of its UIViewController?
Yes, and basically that is normally how things work. When you have a view-controller assigned as the delegate for a view, you are telling it that the view-controller will handle most methods calls for the view. That's the controller's whole purpose for being. For example, if you have a UIView that contains a UITextField, than your UIViewController will handle the textFieldShouldReturn: call (assuming you have properly setup your UIViewController as the delegate for the UIView and told it to implement the TextFieldDelegate protocol)
What method are you trying to call?
how do i assign the pointer to the view controller?
i have subclassed UIView, added a pointer to my subclass of UIViewController.
now i want to assign the pointer assigned as in ViewDidLoad of UIViewController:
myView.viewControllerPtr = self;
if I call in myView [ viewController method ]; The method is not called. I have no compile errors or warnings.
What is going wrong?
First, if you are setting:
Code:
myView.viewControllerPtr = self;
then you'll need to call methods via:
Code:
[viewControllerPtr method];
I'm sure that's what you meant to say, right?
I think some more details of what you have your UIView and UIViewController doing and what it is you're trying to accomplish will help us to answer your question better. That is, be more specific.