我必須調用視圖控制器中存在的方法,該視圖控制器的引用在視圖中可用。當我嘗試像任何其他方法一樣調用方法時,出於某種原因,iPhone只是忽略了該調用。有人可以解釋爲什麼會發生這種情況,我該如何去調用這種方法呢?從視圖調用視圖控制器中的方法
在視圖中我有這樣的方法:
-(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;
}
}
}
每當觸摸事件被觸發,Hellooooo被印在控制檯但在此之前,該方法會被忽略
你可以張貼一些代碼? – itsmatt 2010-03-31 17:12:11