首先,我将尽可能清楚地介绍上下文(如果需要请问它我可以添加一些截图)。
我实际上正在开发一个管理很多可拖动视图的应用程序(称为PostIts)。这些PostIts存储在其他不可拖动的视图中。
要对其进行成像,就好像我有2个遥远的盒子里面有许多PostIts:
| * | |* *|
|* *| <- distance -> | * |
|____| |____|
我的问题:当我开始在视图中拖动一个实际包含它的PostIt时,没有问题。 但是,当我试图超越实际视图去另一个(例如)时,PostIt在遇到视图边框时开始消失。
| * | |* *|
|* *--> disappearing.. | * |
|____| |____|
返回我的图像示例,就像当你在一个盒子中选择一个PostIt并将其移入其中时,这一切都很好。但是当你走出盒子去另一个时,PostIt会变得隐形但是你仍然拥有它,因为当你把另一个盒子中的隐形PostIt掉落时它会重新出现(我有了)一些方法在排序框中重新加载数据。
| * | |* *|
|* *--> disappearing --> * *| ..reappearing
|____| |____|
我尝试了什么:实际上我正在使用Z-index的一些东西,但这并不是真正的结论,我有很多错误:(这段代码实际上在我的{{ 1}})
UIPanGestureRecognizer
以下是另外10个尝试不合情合理的尝试:
if (recognizer.state == UIGestureRecognizerStateBegan) {
CGPoint begin; // Creating a point because you can't directly change the x and t attribute of a point, you have to change the whole point
begin = selectpostit.postItC.centerOfThePostit;
begin.x -= _collectionView.contentOffset.x;
begin.y -= _collectionView.contentOffset.y;
selectpostit.center = begin;
}
[self.view insertSubview:selectpostit aboveSubview:self.view];
也许我不能很好地使用这些方法?
我的问题:在我们开始时,没有一种简单的方法可以将视图放在所有其他视图(绝对是其他所有视图)之前dragNdrop(所以使用 CGPoint tmpPoint = selectpostit.center;
[[UIApplication sharedApplication].keyWindow addSubview:selectpostit];
selectpostit.center = tmpPoint;
self.view.layer.zPosition=1;
self.collectionView.layer.zPosition=1;
selectpostit.layer.zPosition = 1;
[self.view bringSubviewToFront:selectpostit];
[_collectionView bringSubviewToFront:selectpostit];
[selectpostit.superview bringSubviewToFront:selectpostit];
[self.view insertSubview:selectpostit atIndex:1];
)?
答案 0 :(得分:1)
确保PostIt容器视图的clipsToBounds
属性没有值。