判断touch在一个View上
UIView *temomoveView = [[UIView alloc] initWithFrame:CGRectMake(0, 200, 320, 280)]; self.moveView = temomoveView; [temomoveView release]; [moveView setBackgroundColor:[UIColor whiteColor]]; [moveLable setBackgroundColor:[UIColor yellowColor]]; [moveLable setTextAlignment:UITextAlignmentCenter]; [moveLable setText:@"lable Text"]; [moveView addSubview:moveLable]; [self.view addSubview:moveView]; //设了一个事件监听 UITapGestureRecognizer *tapgr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)]; [moveView addGestureRecognizer:tapgr]; [tapgr release];
然后实现tap: 方法就行了