Calling a method in a view controller from a view
- by Lakshmie
I have to invoke a method present in a view controller who's reference is available in the view. When I try to call the method like any other method, for some reason, iPhone just ignores the call. Can somebody explain as to why this happens and also how can I go about invoking this method?
In the view I have this method:
-(void) touchesBegan :(NSSet *) touches withEvent:(UIEvent *)event{
NSArray* mySubViews = [self subviews];
for (UITouch *touch in touches) {
int i = 0;
for(; i<[mySubViews count]; i++){
if(CGRectContainsPoint([[mySubViews objectAtIndex:i] frame], [touch locationInView:self])){
break;
}
}
if(i<[mySubViews count]){
// viewController is the reference to the View Controller.
[viewController pointToSummary:[touch locationInView:self].y];
NSLog(@"Helloooooo");
break;
}
}
}
Whenever the touches event is triggered, Hellooooo gets printed in the console but the method before that is simply ignored