//从我的评论
建在c部分你有,tileView.frame = CGRectMake(targetView.frame.origin.x,targetView.frame.origin.y,20,20);我会认为,因为你做targetView.frame.origin.x,targetView.frame.origin.y,它只是把它从屏幕上。我认为它应该是0,0作为你的添加来查看你的坐标。
-(void)placeTile:(TileView*)tileView atTarget:(TargetView*)targetView {
[UIView animateWithDuration:0.35 delay:0.00 options:UIViewAnimationOptionCurveEaseOut animations:^{
[tileView removeFromSuperview];
tileView.frame=CGRectMake(targetView.frame.origin.x, targetView.frame.origin.y, 20, 20);
[targetView addSubview:tileView];
NSLog(@"%f,%f,%f,%f",tileView.frame.origin.x,tileView.frame.origin.y,tileView.frame.size.width,tileView.frame.size.height);
[tileView bringSubviewToFront:targetView];
}
completion:^(BOOL finished){
}];
请参阅设置tileview具有相同的X和Y的TargetView但你添加到目标视图。我想你想把它放在0,0或者可以转换点。
[UIView animateWithDuration:0.35 delay:0.00 options:UIViewAnimationOptionCurveEaseOut
animations:^{
tileView.frame=CGRectMake(0, 0, 20, 20);
[targetView addSubview:tileView];
}
completion:^(BOOL finished){
}];
编辑:
iMobile使得一个好点的苹果的文档说,addSubview删除了该视图,如果加上之前已经有一个超级。
"Views can have only one superview. If view already has a superview and that view is
not the receiver, this method removes the previous superview before making the
receiver its new superview."
在c部分你有,tileView.frame = CGRectMake(targetView.frame.origin.x,targetView.frame.origin.y,20,20);我会认为,因为你做targetView.frame.origin.x,targetView.frame.origin.y,它只是把它从屏幕上。我认为它应该是0,0作为你的添加来查看你的坐标。 – BooRanger
@Boo:添加ileView.frame = CGRectMake(0,0,20,20)后不工作。 –
然后将它作为前景,并在它与任何子视图相交时检查[A子视图]的再次交集点,然后将拖动视图添加为相交视图的子视图。 –