Quote:
Originally Posted by kgodard
This seems like it should be simple to me, but I'm having a hard time finding a way to do it. I have a class that builds a view that has a button within it. I need that button to make something happen in the view that I've got an object of the class in. I've setup the button to call an action from within the class.
[myButton addTarget:self action:@selector(testAction  forControlEvents:UIControlEventTouchUpInside];
This calls the following function within the class.
- (void)testAction  id)sender{
}
Within this I need to be able to call a function in the view that I have the class in. I have a function ready in the view that hides the class and does some other stuff when it runs. I need a way to run this function from the testAction or a better way to make it happen.
|
From what I understand, the structure of your program is the following:
RootView ->contains-> YourClass ->contains -> anotherView
and you need to call a method in RootView from YourClass.
If this is the case then you need some way do address RootView from within YourClass. You could simply create a class variable i.e. a pointer to a View of type RootView. Then when you create YourClass inside the RootView, you could set that pointer to the RootView.
example:
in RootView
YourClass *c = [[YourClass alloc] init];
[c setRootView:self];
Then in your testAction method, you could call:
[self.rootView doYourThing];
Hope it helps