【发布时间】:2014-05-06 11:59:21
【问题描述】:
我在视图中添加了一个UIView(“Box”),我想检测其中的触摸。
我在谷歌和这个网站上搜索并找到了很多答案,但我希望当触摸框视图(仅框视图)时在控制台NSLog("1") 中显示我,并且当触摸我的视图时 except 框地方(在其他到开箱即用的地方查看我的控制台给我看NSLog("2"))
我很困惑,请帮助我。这是我的代码:
@interface RootViewController : UIViewController
@property (nonatomic,strong) UIView *Box;
@end
@implementation RootViewController
@synthesize window,Box;
- (void)viewDidLoad
{
[super viewDidLoad];
Box = [[UIView alloc] initWithFrame:CGRectMake(53.0, 100.0, 214, 124)];
[Box setBackgroundColor:[UIColor greenColor]];
[self.view addSubview:Box];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
CGPoint locationPoint = [[touches anyObject] locationInView:self.view];
}
【问题讨论】:
标签: objective-c uiview touch uitouch