我有一个view1,view2和view3。 view2是view1的子视图,view3是view2的子视图。我想在view1和view2中移动view3,但是当我在view1中释放它时,我无法再次选择它。
以下是我尝试过的代码。
UIPanGestureRecognizer* panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
[self.thriedView addGestureRecognizer:panGesture];
- (void) handlePan: (UIPanGestureRecognizer*) panGesture {
if (panGesture.state == UIGestureRecognizerStateChanged) {
CGPoint translation = [panGesture translationInView:panGesture.view];
panGesture.view.center = CGPointMake(panGesture.view.center.x + translation.x,
panGesture.view.center.y + translation.y);
[panGesture setTranslation:CGPointZero inView:panGesture.view];
}
}
答案 0 :(得分:0)
在第二个视图之外发布第三个视图后,它就在超级视图之外。默认情况下,其超级视图外的视图不能被触摸(即,它不能接收触摸事件)。这就是为什么你“不能再选择它了”。