【发布时间】:2013-05-26 19:01:20
【问题描述】:
我有两个类,BoxNinjaViewController(Xcode 创建的默认视图)和GameClass。 GameClass 作为子视图加载,如下所示:
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
关于发生了什么以及如何解决它的任何想法?这就是我设置我以前所有应用程序的方式,我从来没有遇到过这个问题。
【问题讨论】:
标签: ios objective-c uiview touchesbegan touches