简而言之,我想检测导航控制器标题栏上的触摸,但实际上无法捕捉到任何触摸!
一切都在没有 IB 的情况下完成,如果这有所作为的话。
我的应用委托的 .m 文件包含:
MyViewController *viewController = [[MyViewController alloc] init];
navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[window addSubview:navigationController.view];
在此窗口中添加了一些其他子视图,这些子视图覆盖了 navigationController,只留下了导航栏可见。
MyViewController 是 UIViewController 的子类,它的 .m 文件包含:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
for (UITouch *touch in touches) {
NSLog(@"ended\n");
}
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches) {
NSLog(@"began\n");
}
}
我还尝试将这些函数直接放入应用程序委托的 .m 文件中,但控制台仍然是空白的。
我究竟做错了什么?