触摸识别的应用

问题描述

|                                                                                                                       

解决方法

简单,只需使用IB,然后首先添加UIImageView并用菜单的背景图像填充即可。然后在该UIImageView的顶部添加一些UIButton。然后通过IB中的连接选项卡将这些按钮连接到代码中的方法...     ,您可以使用UIButton和IBAction,也可以通过触摸菜单项的图像框内部来执行此操作:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];

    if ([touch view] == MenuItem1) { (the method you\'re going to use) }

}