2013-05-26 17 views
1

我有兩個類,BoxNinjaViewController(由Xcode創建的默認視圖)和GameClass。 GameClass加載爲子視圖,就像這樣:子視圖調用superview的方法中的觸摸

GameClass *game = [[GameClass alloc] initWithNibName:@"GameClass" bundle:nil]; 
[self.view addSubview: game.view]; 

的GameClass視圖看起來像正常的,但是當我嘗試添加touchesBegan:方法,它的表現很奇怪。

在BoxNinjaViewController.m,我有:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 
    NSLog(@"sauce"); 
} 

和GameClass.m,我有:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 
    NSLog(@"tuna"); 
} 

...當我在GameClass的視圖中單擊,它NSLogs

2013-05-26 14:54:24.908 BoxNinja[75023:c07] sauce 

任何想法是怎麼回事,我該如何解決它?這是他如何設置我以前的所有應用程序,我從來沒有遇到過這個問題。

回答

0

不知何故,使game對象屬性爲BoxNinjaViewController修復它。我想它阻止了它被autoreleased或什麼?

相關問題